# HG changeset patch # User nelopauselli # Date 1317250964 10800 # Node ID e5959f3405e0ab9554847ae77f72952b4e0d0dbb # Parent e38d53a1ead968f1518c2dc22baaebc4d8a30578 Eventos sin ponentes diff -r e38d53a1ead9 -r e5959f3405e0 Agendas/trunk/src/Agendas.Domain/Agenda.cs --- a/Agendas/trunk/src/Agendas.Domain/Agenda.cs Wed Sep 28 19:19:33 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Domain/Agenda.cs Wed Sep 28 20:02:44 2011 -0300 @@ -48,9 +48,19 @@ public EventoResultado ModificarEvento(Guid eventoId, string titulo, Guid ponenteId, DateTime? fechaInicio, DateTime? fechaTermino, string urlInvitacion) { - Evento evento = GetEvento(eventoId); - Persona persona = _personaRepository.Get(ponenteId); + Evento evento = GetEvento(eventoId); + + if (evento.Tipo == TipoEvento.Van && ponenteId == Guid.Empty) + return new EventoResultado(false, "Debe indicar el ponente para este tipo de evento", null); + Persona persona = null; + if (ponenteId != Guid.Empty) + { + persona = _personaRepository.Get(ponenteId); + if (persona == null) + return new EventoResultado(false, string.Format("No se encontró el ponente indicado ({0})", ponenteId), null); + } + if (evento.Titulo != titulo) evento.CambiarTitulo(titulo); @@ -92,23 +102,24 @@ return new EventoResultado(true,"Evento propuesto", warnings); } - public EventoResultado Agendar(string titulo, Guid ponenteId, DateTime? fechaInicio, DateTime? fechaTermino, string urlInvitacion, TipoEvento tipo) - { - return Agendar(titulo, ponenteId, fechaInicio, fechaTermino, urlInvitacion, tipo, null); - } - - public EventoResultado Agendar(string titulo, Guid ponenteId, DateTime? fechaInicio, DateTime? fechaTermino, string urlInvitacion, TipoEvento tipo, IEnumerable colaboradoresId) + public EventoResultado Agendar(string titulo, Guid ponenteId, DateTime? fechaInicio, DateTime? fechaTermino, string urlInvitacion, TipoEvento tipo, IEnumerable colaboradoresId = null) { if (!fechaInicio.HasValue) return new EventoResultado(false, "Debe indicar la fecha", null); if (!fechaTermino.HasValue) return new EventoResultado(false, "Debe indicar la hora y duración", null); + if (tipo==TipoEvento.Van && ponenteId == Guid.Empty) + return new EventoResultado(false, "Debe indicar el ponente para este tipo de evento", null); - Persona persona = _personaRepository.Get(ponenteId); - if (persona == null) - return new EventoResultado(false, string.Format("No se encontró el ponente indicado ({0})", ponenteId), null); + Persona persona = null; + if (ponenteId != Guid.Empty) + { + persona = _personaRepository.Get(ponenteId); + if (persona == null) + return new EventoResultado(false, string.Format("No se encontró el ponente indicado ({0})", ponenteId), null); + } - var existeOtroEvento = _eventosRepository.GetNoPropuestoByTitulo(titulo); + var existeOtroEvento = _eventosRepository.GetNoPropuestoByTitulo(titulo); if (existeOtroEvento != null) return new EventoResultado(false, string.Format( diff -r e38d53a1ead9 -r e5959f3405e0 Agendas/trunk/src/Agendas.Domain/Evento.cs --- a/Agendas/trunk/src/Agendas.Domain/Evento.cs Wed Sep 28 19:19:33 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Domain/Evento.cs Wed Sep 28 20:02:44 2011 -0300 @@ -100,7 +100,7 @@ public virtual IEnumerable Ponentes { - get { return new List {Ponente}.Union(OtrosPonentes); } + get { return Ponente != null ? new List {Ponente}.Union(OtrosPonentes) : OtrosPonentes; } } public virtual void ActualizarOtrosPonentes(IEnumerable otrosPonentes) diff -r e38d53a1ead9 -r e5959f3405e0 Agendas/trunk/src/Agendas.Google.Test/PublicadorTest.cs --- a/Agendas/trunk/src/Agendas.Google.Test/PublicadorTest.cs Wed Sep 28 19:19:33 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Google.Test/PublicadorTest.cs Wed Sep 28 20:02:44 2011 -0300 @@ -199,5 +199,29 @@ Assert.That(detail.Summary, Is.StringContaining("Carlos Peix y Nelo Pauselli.")); } + + [Test] + public void PublicarSinPonente() + { + var adapter = new Mock(); + var detail = new VanGEventDetail(); + var fechaInicio = new DateTime(2011, 07, 09, 18, 0, 0, DateTimeKind.Utc); + var fechaTermino = fechaInicio.AddHours(2); + + var publicador = new GooglePublicador(adapter.Object); + var agenda = new Agenda(publicador, DefaultEventoRepository, DefaultPersonaRepository); + agenda.Agendar("Identity Providers Públicos y Empresariales", Guid.Empty, fechaInicio, + fechaTermino, "https://groups.google.com/d/topic/altnet-hispano/arYEMsPiAtY/discussion", + TipoEvento.Cafe); + + var ev = DefaultEventoRepository.GetActivos()[0]; + detail.Generate(ev); + + Assert.AreEqual("La comunidad ALT.NET Hispano (http://altnethispano.org) realizará un Café sobre Identity Providers Públicos y Empresariales." + + "\n\rFecha: sábado, 09 de julio de 2011 a las 18:00 hrs. Hora Internacional (GMT/UTC), con una duración aproximada de 2 horas." + + "\n\rPueden plantear sus comentarios e inquietudes sobre el tema de la reunión en: https://groups.google.com/d/topic/altnet-hispano/arYEMsPiAtY/discussion" + + "\n\rPara mayor información sobre cómo atender la reunión consulten: http://tinyurl.com/van-hispano" + + "\n\rPueden vincular el Google Calendar al suyo (http://screenr.com/nr7)", detail.Summary); + } } } \ No newline at end of file diff -r e38d53a1ead9 -r e5959f3405e0 Agendas/trunk/src/Agendas.Google/DetailsEvents/VanGEventDetail.cs --- a/Agendas/trunk/src/Agendas.Google/DetailsEvents/VanGEventDetail.cs Wed Sep 28 19:19:33 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Google/DetailsEvents/VanGEventDetail.cs Wed Sep 28 20:02:44 2011 -0300 @@ -9,7 +9,7 @@ public class VanGEventDetail : IGEventDetail { private const string TextoVan = - "La comunidad ALT.NET Hispano (http://altnethispano.org) realizará una VAN sobre [NOMBRE], con [NOMBRE_EXPOSITOR]." + + "La comunidad ALT.NET Hispano (http://altnethispano.org) realizará [EVENTO_TIPO] sobre [NOMBRE][NOMBRE_EXPOSITOR]." + "\n\rFecha: [FECHA] a las 18:00 hrs. Hora Internacional (GMT/UTC), con una duración aproximada de 2 horas." + "\n\rPueden plantear sus comentarios e inquietudes sobre el tema de la reunión en: [URL_DISCUCION]" + "\n\rPara mayor información sobre cómo atender la reunión consulten: http://tinyurl.com/van-hispano" + @@ -30,10 +30,32 @@ EndEvent = evento.FechaTermino.Value; var cultureInfo = new CultureInfo( "es-ES", false ).DateTimeFormat; - Summary = TextoVan.Replace("[NOMBRE]", evento.Titulo). - Replace("[NOMBRE_EXPOSITOR]", evento.GetPonentesAsString(p => p.Nombre)). + Summary = TextoVan.Replace("[EVENTO_TIPO]", GetEventoTipo(evento.Tipo)). + Replace("[NOMBRE]", evento.Titulo). + Replace("[NOMBRE_EXPOSITOR]", GetPonentes(evento)). Replace("[FECHA]", StartEvent.ToString("D", cultureInfo)). Replace("[URL_DISCUCION]", evento.UrlInvitacion); } + + private static string GetPonentes(Evento evento) + { + var ponentes = evento.GetPonentesAsString(p => p.Nombre); + return !string.IsNullOrWhiteSpace(ponentes) ? string.Format(", con {0}", ponentes) : string.Empty; + } + + private static string GetEventoTipo(TipoEvento tipo) + { + switch (tipo) + { + case TipoEvento.Van: + return "una VAN"; + case TipoEvento.Cafe: + return "un Café"; + case TipoEvento.GrupoEstudio: + return "un Grupo de estudio"; + default: + return string.Empty; + } + } } } diff -r e38d53a1ead9 -r e5959f3405e0 Agendas/trunk/src/Agendas.Tests/AgendarTests.cs --- a/Agendas/trunk/src/Agendas.Tests/AgendarTests.cs Wed Sep 28 19:19:33 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Tests/AgendarTests.cs Wed Sep 28 20:02:44 2011 -0300 @@ -84,7 +84,7 @@ } [Test] - public void Intentar_agendar_evento_sin_ponente() + public void Intentar_agendar_van_sin_ponente() { var agenda = new Agenda(null, DefaultEventoRepository, DefaultPersonaRepository); @@ -96,6 +96,30 @@ } [Test] + public void Agendar_cafe_sin_ponente() + { + var agenda = new Agenda(null, DefaultEventoRepository, DefaultPersonaRepository); + + var fechaInicio = DateTime.Now.ToUniversalTime(); + var fechaTermino = fechaInicio.AddHours(2); + var r = agenda.Agendar("Cafe para publicar", Guid.Empty, fechaInicio, fechaTermino, urlInvitacion, TipoEvento.Cafe); + + Assert.IsTrue(r.Succeful); + } + + [Test] + public void Agendar_grupo_de_estudio_sin_ponente() + { + var agenda = new Agenda(null, DefaultEventoRepository, DefaultPersonaRepository); + + var fechaInicio = DateTime.Now.ToUniversalTime(); + var fechaTermino = fechaInicio.AddHours(2); + var r = agenda.Agendar("GrupoEstudio para publicar", Guid.Empty, fechaInicio, fechaTermino, urlInvitacion, TipoEvento.GrupoEstudio); + + Assert.IsTrue(r.Succeful); + } + + [Test] public void Agendar_evento_con_multiples_publicadores() { var publicador1 = new Mock(); diff -r e38d53a1ead9 -r e5959f3405e0 Agendas/trunk/src/Agendas.Tests/PonentesTests.cs --- a/Agendas/trunk/src/Agendas.Tests/PonentesTests.cs Wed Sep 28 19:19:33 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Tests/PonentesTests.cs Wed Sep 28 20:02:44 2011 -0300 @@ -94,35 +94,68 @@ } [Test] - public void Quitar_ponente_de_un_evento() + public void Quitar_ponente_de_una_van() { var agenda = new Agenda(null, DefaultEventoRepository, DefaultPersonaRepository); const string titulo = "Audit (parallel model) con NHibernate 3"; Guid eventoId; - agenda.Proponer(titulo, TestsHelper.GetOrCreatePonente("Fabio"), urlInvitacion, TipoEvento.Van); - Persona persona; - { - var eventos = agenda.GetEventosActivos(EventoPropuestoState.GetInstance()); + DateTime fechaInicio=DateTime.Now; + + var r = agenda.Agendar(titulo, TestsHelper.GetOrCreatePonente("Fabio"), fechaInicio, fechaInicio.AddHours(2), urlInvitacion, TipoEvento.Van); + { + Assert.IsTrue(r.Succeful); + + var eventos = agenda.GetEventosActivos(EventoAgendadoState.GetInstance()); Assert.AreEqual(1, eventos.Count); Evento evento = eventos[0]; Assert.AreEqual("Fabio", evento.Ponente.Nombre); eventoId = evento.Id; - persona = evento.Ponente; } - agenda.ModificarPropuesta(eventoId, titulo, Guid.Empty, urlInvitacion); - { - var eventos = agenda.GetEventosActivos(EventoPropuestoState.GetInstance()); - Assert.AreEqual(1, eventos.Count); + r = agenda.ModificarEvento(eventoId, titulo, Guid.Empty, fechaInicio, fechaInicio.AddHours(2), urlInvitacion); + Assert.IsFalse(r.Succeful); + + } + + [Test] + public void Quitar_ponente_de_un_cafe() + { + var agenda = new Agenda(null, DefaultEventoRepository, DefaultPersonaRepository); + + const string titulo = "Audit (parallel model) con NHibernate 3"; + Guid eventoId; + + DateTime fechaInicio = DateTime.Now; + + var r = agenda.Agendar(titulo, TestsHelper.GetOrCreatePonente("Fabio"), fechaInicio, fechaInicio.AddHours(2), urlInvitacion, TipoEvento.Cafe); + { + Assert.IsTrue(r.Succeful); - Evento evento = eventos[0]; - Assert.IsNull(evento.Ponente); - } - } + var eventos = agenda.GetEventosActivos(EventoAgendadoState.GetInstance()); + Assert.AreEqual(1, eventos.Count); + + Evento evento = eventos[0]; + Assert.AreEqual("Fabio", evento.Ponente.Nombre); + + eventoId = evento.Id; + } + + r = agenda.ModificarEvento(eventoId, titulo, Guid.Empty, fechaInicio, fechaInicio.AddHours(2), urlInvitacion); + { + Console.WriteLine(r.Message); + Assert.IsTrue(r.Succeful); + + var eventos = agenda.GetEventosActivos(EventoAgendadoState.GetInstance()); + Assert.AreEqual(1, eventos.Count); + + Evento evento = eventos[0]; + Assert.IsNull(evento.Ponente); + } + } [Test] public void Cambiar_ponente_de_un_evento() diff -r e38d53a1ead9 -r e5959f3405e0 Agendas/trunk/src/Agendas.Twitter.Tests/Publicador_tests.cs --- a/Agendas/trunk/src/Agendas.Twitter.Tests/Publicador_tests.cs Wed Sep 28 19:19:33 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Twitter.Tests/Publicador_tests.cs Wed Sep 28 20:02:44 2011 -0300 @@ -102,5 +102,35 @@ adapter.Verify(a => a.Update(It.IsAny(), out message), Times.Exactly(2)); } + + [Test] + public void Evento_sin_ponente() + { + var adapter = new Mock(); + + string message; + var twitters = new List(); + adapter.Setup(a => a.Update(It.IsAny(), out message)).Returns(true).Callback((status, m) => twitters.Add(status)); + + var publicador = new TwitterPublicador(adapter.Object); + var agenda = new Agenda(publicador, DefaultEventoRepository, DefaultPersonaRepository); + + var inicio = DateTime.Now.AddDays(3); + + agenda.Agendar("Identity Providers Públicos y Empresariales", Guid.Empty, inicio, inicio.AddHours(2), null, TipoEvento.Cafe); + + Assert.IsTrue(twitters.Any()); + var joined = string.Empty; + foreach (var twitter in twitters) + { + Console.WriteLine(twitter); + Assert.LessOrEqual(twitter.Length, 140); + joined += twitter; + } + Assert.AreEqual("Se ha agendando el evento Identity Providers Públicos y Empresariales para el 01/10/2011 por http://snipr.com/virtualaltnet", joined); + + adapter.Verify(a => a.Update(It.IsAny(), out message), Times.Once()); + + } } } \ No newline at end of file diff -r e38d53a1ead9 -r e5959f3405e0 Agendas/trunk/src/Agendas.Twitter/Recordatorios.cs --- a/Agendas/trunk/src/Agendas.Twitter/Recordatorios.cs Wed Sep 28 19:19:33 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Twitter/Recordatorios.cs Wed Sep 28 20:02:44 2011 -0300 @@ -19,8 +19,8 @@ for (int hora = 3; hora > 0; hora--) { - var mensaje = TwitterStringHelper.TipoEvento(evento.Tipo) + " sobre " + evento.Titulo + " con " + - TwitterStringHelper.Ponente(evento.Ponente) + " inicia en [" + hora + "] hora" + + var mensaje = TwitterStringHelper.TipoEvento(evento.Tipo) + " sobre " + evento.Titulo + + TwitterStringHelper.Ponentes(evento) + " inicia en [" + hora + "] hora" + (hora > 1 ? "s" : string.Empty) + " " + TwitterStringHelper.Hora(fechaInicio) + " http://snipr.com/virtualaltnet"; @@ -28,8 +28,8 @@ Items.Add(new RecordatorioItem(fechaRecordatorio, mensaje)); } - var mensaje15 = TwitterStringHelper.TipoEvento(evento.Tipo) + " sobre " + evento.Titulo + " con " + - TwitterStringHelper.Ponente(evento.Ponente) + " inicia en [15] minutos " + + var mensaje15 = TwitterStringHelper.TipoEvento(evento.Tipo) + " sobre " + evento.Titulo + + TwitterStringHelper.Ponentes(evento) + " inicia en [15] minutos " + TwitterStringHelper.Hora(fechaInicio) + " http://snipr.com/virtualaltnet"; var fechaRecordatorio15 = fechaInicio.AddMinutes(-15); diff -r e38d53a1ead9 -r e5959f3405e0 Agendas/trunk/src/Agendas.Twitter/TwitterStringHelper.cs --- a/Agendas/trunk/src/Agendas.Twitter/TwitterStringHelper.cs Wed Sep 28 19:19:33 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Twitter/TwitterStringHelper.cs Wed Sep 28 20:02:44 2011 -0300 @@ -20,9 +20,10 @@ } } - public static string Ponente(Persona ponente) + public static string Ponentes(Evento evento) { - return "@"+ponente.Twitter; + var ponentes = evento.GetPonentesAsString(p => "@" + p.Twitter); + return !string.IsNullOrWhiteSpace(ponentes) ? " con " + ponentes : string.Empty; } public static string Hora(DateTime fechaInicio) diff -r e38d53a1ead9 -r e5959f3405e0 Agendas/trunk/src/Agendas.Twitter/Writers/AgendarTwitterWriter.cs --- a/Agendas/trunk/src/Agendas.Twitter/Writers/AgendarTwitterWriter.cs Wed Sep 28 19:19:33 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Twitter/Writers/AgendarTwitterWriter.cs Wed Sep 28 20:02:44 2011 -0300 @@ -9,7 +9,7 @@ return new[] { "Se ha agendando el evento " + track.Evento.Titulo, - " con " + TwitterHelper.GetPonentes(track.Evento), + TwitterHelper.GetPonentes(track.Evento), track.Evento.FechaInicio.HasValue ? " para el " + track.Evento.FechaInicio.Value.ToShortDateString() : string.Empty, diff -r e38d53a1ead9 -r e5959f3405e0 Agendas/trunk/src/Agendas.Twitter/Writers/ConfirmarTwitterWriter.cs --- a/Agendas/trunk/src/Agendas.Twitter/Writers/ConfirmarTwitterWriter.cs Wed Sep 28 19:19:33 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Twitter/Writers/ConfirmarTwitterWriter.cs Wed Sep 28 20:02:44 2011 -0300 @@ -12,7 +12,7 @@ { "Se confirma para el " + track.Evento.FechaInicio.Value.ToShortDateString(), " el evento " + track.Evento.Titulo, - " con " + TwitterHelper.GetPonentes(track.Evento) + TwitterHelper.GetPonentes(track.Evento) }; return new[] {string.Empty}; } diff -r e38d53a1ead9 -r e5959f3405e0 Agendas/trunk/src/Agendas.Twitter/Writers/PublicarTwitterWriter.cs --- a/Agendas/trunk/src/Agendas.Twitter/Writers/PublicarTwitterWriter.cs Wed Sep 28 19:19:33 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Twitter/Writers/PublicarTwitterWriter.cs Wed Sep 28 20:02:44 2011 -0300 @@ -10,7 +10,7 @@ return new[] { "Se ha publicado el video del evento " + track.Evento.Titulo, - " con " + TwitterHelper.GetPonentes(track.Evento) + TwitterHelper.GetPonentes(track.Evento) }; } } diff -r e38d53a1ead9 -r e5959f3405e0 Agendas/trunk/src/Agendas.Twitter/Writers/TwitterHelper.cs --- a/Agendas/trunk/src/Agendas.Twitter/Writers/TwitterHelper.cs Wed Sep 28 19:19:33 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Twitter/Writers/TwitterHelper.cs Wed Sep 28 20:02:44 2011 -0300 @@ -6,7 +6,8 @@ { public static string GetPonentes(Evento evento) { - return evento.GetPonentesAsString(GetPonente); + var ponentes = evento.GetPonentesAsString(GetPonente); + return !string.IsNullOrWhiteSpace(ponentes) ? " con " + ponentes : string.Empty; } private static string GetPonente(Persona ponente) diff -r e38d53a1ead9 -r e5959f3405e0 Agendas/trunk/src/Agendas.Web/DataProviders.cs --- a/Agendas/trunk/src/Agendas.Web/DataProviders.cs Wed Sep 28 19:19:33 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/DataProviders.cs Wed Sep 28 20:02:44 2011 -0300 @@ -18,11 +18,15 @@ public static IEnumerable GetPonentes(this HtmlHelper helper, Guid id) { - var personas = AgendaFactory.GetPersonaService(); - return from p in personas.GetAll() - orderby p.Nombre - select - new SelectListItem {Text = p.Nombre, Value = p.Id.ToString(), Selected = p.Id.Equals(id)}; + var lista = new List {new SelectListItem {Text = "[Ninguno]", Value = Guid.Empty.ToString()}}; + + var personaService = AgendaFactory.GetPersonaService(); + var personas = from p in personaService.GetAll() + orderby p.Nombre + select + new SelectListItem {Text = p.Nombre, Value = p.Id.ToString(), Selected = p.Id.Equals(id)}; + + return lista.Union(personas); } public static IEnumerable GetOtrosPonentes(this HtmlHelper helper, IEnumerable ids) diff -r e38d53a1ead9 -r e5959f3405e0 Agendas/trunk/src/Agendas.Web/Models/EventoModel.cs --- a/Agendas/trunk/src/Agendas.Web/Models/EventoModel.cs Wed Sep 28 19:19:33 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/Models/EventoModel.cs Wed Sep 28 20:02:44 2011 -0300 @@ -20,7 +20,6 @@ [Required] public string Titulo { get; set; } - [Required] public Guid Ponente { get; set; } public Guid[] OtrosPonentes { get; set; } @@ -46,7 +45,6 @@ [Required] public string Titulo { get; set; } - [Required] public Guid Ponente { get; set; } [Required] @@ -70,7 +68,6 @@ [Required] public string Titulo { get; set; } - [Required] public Guid Ponente { get; set; } [Required]