comparison Agendas/trunk/src/Agendas.Domain/Agenda.cs @ 231:e5959f3405e0

Eventos sin ponentes
author nelopauselli
date Wed, 28 Sep 2011 20:02:44 -0300
parents f23ee59ef1bd
children c61954d24c8c
comparison
equal deleted inserted replaced
230:e38d53a1ead9 231:e5959f3405e0
46 return _eventosRepository.GetByState(EventoPublicadoState.GetInstance()) ?? new List<Evento>(); 46 return _eventosRepository.GetByState(EventoPublicadoState.GetInstance()) ?? new List<Evento>();
47 } 47 }
48 48
49 public EventoResultado ModificarEvento(Guid eventoId, string titulo, Guid ponenteId, DateTime? fechaInicio, DateTime? fechaTermino, string urlInvitacion) 49 public EventoResultado ModificarEvento(Guid eventoId, string titulo, Guid ponenteId, DateTime? fechaInicio, DateTime? fechaTermino, string urlInvitacion)
50 { 50 {
51 Evento evento = GetEvento(eventoId); 51 Evento evento = GetEvento(eventoId);
52 Persona persona = _personaRepository.Get(ponenteId); 52
53 53 if (evento.Tipo == TipoEvento.Van && ponenteId == Guid.Empty)
54 return new EventoResultado(false, "Debe indicar el ponente para este tipo de evento", null);
55
56 Persona persona = null;
57 if (ponenteId != Guid.Empty)
58 {
59 persona = _personaRepository.Get(ponenteId);
60 if (persona == null)
61 return new EventoResultado(false, string.Format("No se encontró el ponente indicado ({0})", ponenteId), null);
62 }
63
54 if (evento.Titulo != titulo) 64 if (evento.Titulo != titulo)
55 evento.CambiarTitulo(titulo); 65 evento.CambiarTitulo(titulo);
56 66
57 if (evento.FechaInicio == null && fechaInicio != null && evento.FechaTermino == null && fechaTermino != null) 67 if (evento.FechaInicio == null && fechaInicio != null && evento.FechaTermino == null && fechaTermino != null)
58 evento.Agendar(persona, fechaInicio, fechaTermino, urlInvitacion); 68 evento.Agendar(persona, fechaInicio, fechaTermino, urlInvitacion);
90 var warnings = evento.GetLogsNews().Where(l => !l.Successful); 100 var warnings = evento.GetLogsNews().Where(l => !l.Successful);
91 101
92 return new EventoResultado(true,"Evento propuesto", warnings); 102 return new EventoResultado(true,"Evento propuesto", warnings);
93 } 103 }
94 104
95 public EventoResultado Agendar(string titulo, Guid ponenteId, DateTime? fechaInicio, DateTime? fechaTermino, string urlInvitacion, TipoEvento tipo) 105 public EventoResultado Agendar(string titulo, Guid ponenteId, DateTime? fechaInicio, DateTime? fechaTermino, string urlInvitacion, TipoEvento tipo, IEnumerable<Guid> colaboradoresId = null)
96 {
97 return Agendar(titulo, ponenteId, fechaInicio, fechaTermino, urlInvitacion, tipo, null);
98 }
99
100 public EventoResultado Agendar(string titulo, Guid ponenteId, DateTime? fechaInicio, DateTime? fechaTermino, string urlInvitacion, TipoEvento tipo, IEnumerable<Guid> colaboradoresId)
101 { 106 {
102 if (!fechaInicio.HasValue) 107 if (!fechaInicio.HasValue)
103 return new EventoResultado(false, "Debe indicar la fecha", null); 108 return new EventoResultado(false, "Debe indicar la fecha", null);
104 if (!fechaTermino.HasValue) 109 if (!fechaTermino.HasValue)
105 return new EventoResultado(false, "Debe indicar la hora y duración", null); 110 return new EventoResultado(false, "Debe indicar la hora y duración", null);
106 111 if (tipo==TipoEvento.Van && ponenteId == Guid.Empty)
107 Persona persona = _personaRepository.Get(ponenteId); 112 return new EventoResultado(false, "Debe indicar el ponente para este tipo de evento", null);
108 if (persona == null) 113
109 return new EventoResultado(false, string.Format("No se encontró el ponente indicado ({0})", ponenteId), null); 114 Persona persona = null;
110 115 if (ponenteId != Guid.Empty)
111 var existeOtroEvento = _eventosRepository.GetNoPropuestoByTitulo(titulo); 116 {
117 persona = _personaRepository.Get(ponenteId);
118 if (persona == null)
119 return new EventoResultado(false, string.Format("No se encontró el ponente indicado ({0})", ponenteId), null);
120 }
121
122 var existeOtroEvento = _eventosRepository.GetNoPropuestoByTitulo(titulo);
112 if (existeOtroEvento != null) 123 if (existeOtroEvento != null)
113 return new EventoResultado(false, 124 return new EventoResultado(false,
114 string.Format( 125 string.Format(
115 "Ya existe un evento con el mismo título ({0}) del {1}, por favor ingrese otro.", 126 "Ya existe un evento con el mismo título ({0}) del {1}, por favor ingrese otro.",
116 titulo, existeOtroEvento.FechaInicio.Value.ToShortDateString()), null); 127 titulo, existeOtroEvento.FechaInicio.Value.ToShortDateString()), null);