# HG changeset patch # User Nelo@Kenia.neluz.int # Date 1308499202 10800 # Node ID 53bcd338542b49874c86eb35409e9b6947bcc0a5 # Parent 7a2eeb9e9bf96f3b98157fef70b8eef2fcbe3b8b acciones de confirmar y publicar desde la UI diff -r 7a2eeb9e9bf9 -r 53bcd338542b Agendas/trunk/src/Agendas.Domain/EventoAgendadoState.cs --- a/Agendas/trunk/src/Agendas.Domain/EventoAgendadoState.cs Sun Jun 12 01:40:09 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Domain/EventoAgendadoState.cs Sun Jun 19 13:00:02 2011 -0300 @@ -1,4 +1,5 @@ -using AltNetHispano.Agendas.Domain.Exceptions; +using System; +using AltNetHispano.Agendas.Domain.Exceptions; namespace AltNetHispano.Agendas.Domain { @@ -33,5 +34,10 @@ { return Descripcion; } + + public override bool PuedePromover(Accion accion) + { + return accion == Accion.Confirmar; + } } } \ No newline at end of file diff -r 7a2eeb9e9bf9 -r 53bcd338542b Agendas/trunk/src/Agendas.Domain/EventoConfirmadoState.cs --- a/Agendas/trunk/src/Agendas.Domain/EventoConfirmadoState.cs Sun Jun 12 01:40:09 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Domain/EventoConfirmadoState.cs Sun Jun 19 13:00:02 2011 -0300 @@ -1,4 +1,5 @@ -using AltNetHispano.Agendas.Domain.Exceptions; +using System; +using AltNetHispano.Agendas.Domain.Exceptions; namespace AltNetHispano.Agendas.Domain { @@ -33,5 +34,10 @@ { return Descripcion; } + + public override bool PuedePromover(Accion accion) + { + return accion == Accion.Publicar; + } } } \ No newline at end of file diff -r 7a2eeb9e9bf9 -r 53bcd338542b Agendas/trunk/src/Agendas.Domain/EventoNullState.cs --- a/Agendas/trunk/src/Agendas.Domain/EventoNullState.cs Sun Jun 12 01:40:09 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Domain/EventoNullState.cs Sun Jun 19 13:00:02 2011 -0300 @@ -1,4 +1,5 @@ -using AltNetHispano.Agendas.Domain.Exceptions; +using System; +using AltNetHispano.Agendas.Domain.Exceptions; namespace AltNetHispano.Agendas.Domain { @@ -37,5 +38,10 @@ { return Descripcion; } + + public override bool PuedePromover(Accion accion) + { + return accion == Accion.Proponer || accion == Accion.Agendar; + } } } \ No newline at end of file diff -r 7a2eeb9e9bf9 -r 53bcd338542b Agendas/trunk/src/Agendas.Domain/EventoPropuestoState.cs --- a/Agendas/trunk/src/Agendas.Domain/EventoPropuestoState.cs Sun Jun 12 01:40:09 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Domain/EventoPropuestoState.cs Sun Jun 19 13:00:02 2011 -0300 @@ -1,4 +1,5 @@ -using AltNetHispano.Agendas.Domain.Exceptions; +using System; +using AltNetHispano.Agendas.Domain.Exceptions; namespace AltNetHispano.Agendas.Domain { @@ -33,5 +34,10 @@ { return Descripcion; } + + public override bool PuedePromover(Accion accion) + { + return accion == Accion.Agendar; + } } } \ No newline at end of file diff -r 7a2eeb9e9bf9 -r 53bcd338542b Agendas/trunk/src/Agendas.Domain/EventoPublicadoState.cs --- a/Agendas/trunk/src/Agendas.Domain/EventoPublicadoState.cs Sun Jun 12 01:40:09 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Domain/EventoPublicadoState.cs Sun Jun 19 13:00:02 2011 -0300 @@ -1,4 +1,5 @@ -using AltNetHispano.Agendas.Domain.Exceptions; +using System; +using AltNetHispano.Agendas.Domain.Exceptions; namespace AltNetHispano.Agendas.Domain { @@ -25,5 +26,10 @@ { return Descripcion; } + + public override bool PuedePromover(Accion accion) + { + return false; + } } } \ No newline at end of file diff -r 7a2eeb9e9bf9 -r 53bcd338542b Agendas/trunk/src/Agendas.Domain/EventoState.cs --- a/Agendas/trunk/src/Agendas.Domain/EventoState.cs Sun Jun 12 01:40:09 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Domain/EventoState.cs Sun Jun 19 13:00:02 2011 -0300 @@ -10,5 +10,7 @@ public abstract void Promover(Evento evento, Accion accion); public abstract string GetDescripcion(); + + public abstract bool PuedePromover(Accion accion); } } diff -r 7a2eeb9e9bf9 -r 53bcd338542b Agendas/trunk/src/Agendas.Web/Controllers/EventoController.cs --- a/Agendas/trunk/src/Agendas.Web/Controllers/EventoController.cs Sun Jun 12 01:40:09 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/Controllers/EventoController.cs Sun Jun 19 13:00:02 2011 -0300 @@ -13,12 +13,20 @@ { var agenda = AgendaFactory.GetAgenda(); - var model = new EventoIndexModel - { - ProximosEventos = from e in agenda.GetEventosAgendados() - orderby e.Fecha - select new EventoDto { Id = e.Id.ToString(), Titulo = e.Titulo, Fecha = e.Fecha.Value } - }; + var model = new EventoIndexModel + { + ProximosEventos = from e in agenda.GetEventosAgendados() + orderby e.Fecha + select new EventoDto + { + Id = e.Id.ToString(), + Titulo = e.Titulo, + Fecha = e.Fecha.Value, + PuedeModificar = e.GetEstado().PuedePromover(Accion.Modificar), + PuedeConfirmar = e.GetEstado().PuedePromover(Accion.Confirmar), + PuedePublicar = e.GetEstado().PuedePromover(Accion.Publicar) + } + }; return View(model); } @@ -63,6 +71,22 @@ return View(model); } + [Authorize] + public ActionResult Confirm(string id) + { + var agenda = AgendaFactory.GetAgenda(); + agenda.Confirmar(new Guid(id)); + return RedirectToAction("Index"); + } + + [Authorize] + public ActionResult Publish(string id) + { + var agenda = AgendaFactory.GetAgenda(); + agenda.Publicar(new Guid(id), 0, string.Empty); + return RedirectToAction("Index"); + } + [HttpPost] [Authorize] public ActionResult Edit(EventoEditModel model) diff -r 7a2eeb9e9bf9 -r 53bcd338542b Agendas/trunk/src/Agendas.Web/Models/EventoModel.cs --- a/Agendas/trunk/src/Agendas.Web/Models/EventoModel.cs Sun Jun 12 01:40:09 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/Models/EventoModel.cs Sun Jun 19 13:00:02 2011 -0300 @@ -66,5 +66,9 @@ public string Id { get; set; } public string Titulo { get; set; } public DateTime Fecha { get; set; } + + public bool PuedeModificar { get; set; } + public bool PuedeConfirmar { get; set; } + public bool PuedePublicar { get; set; } } } \ No newline at end of file diff -r 7a2eeb9e9bf9 -r 53bcd338542b Agendas/trunk/src/Agendas.Web/Views/Evento/Index.cshtml --- a/Agendas/trunk/src/Agendas.Web/Views/Evento/Index.cshtml Sun Jun 12 01:40:09 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/Views/Evento/Index.cshtml Sun Jun 19 13:00:02 2011 -0300 @@ -18,8 +18,18 @@ @item.Fecha.ToShortDateString() @item.Titulo - @Html.ActionLink("Modificar", "Edit", new { id = item.Id }) - @Html.ActionLink("Confirmar", "Confirm", new { id = item.Id }) + @if (item.PuedeModificar) + { + @Html.ActionLink("Modificar", "Edit", new { id = item.Id }) + } + @if (item.PuedeConfirmar) + { + @Html.ActionLink("Confirmar", "Confirm", new { id = item.Id }) + } + @if (item.PuedePublicar) + { + @Html.ActionLink("Publicar", "Publish", new { id = item.Id }) + } }