Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.Web/Controllers/EventoController.cs @ 118:b74734a1a755
Manejo de eventos por estado
author | Nelo@Kenia.neluz.int |
---|---|
date | Wed, 22 Jun 2011 09:32:59 -0300 |
parents | 7ef7e4bb71f6 |
children | 6f1041301797 |
comparison
equal
deleted
inserted
replaced
117:7ef7e4bb71f6 | 118:b74734a1a755 |
---|---|
12 public ActionResult Index() | 12 public ActionResult Index() |
13 { | 13 { |
14 var agenda = AgendaFactory.GetAgenda(); | 14 var agenda = AgendaFactory.GetAgenda(); |
15 | 15 |
16 var model = new EventoIndexModel | 16 var model = new EventoIndexModel |
17 { | 17 { |
18 ProximosEventos = from e in agenda.GetEventosAgendados() | 18 ProximosEventos = from e in agenda.GetEventosActivos() |
19 orderby e.Fecha | 19 orderby e.Fecha |
20 select new EventoDto | 20 select new EventoDto |
21 { | 21 { |
22 Id = e.Id.ToString(), | 22 Id = e.Id.ToString(), |
23 Titulo = e.Titulo, | 23 Titulo = e.Titulo, |
24 Fecha = e.Fecha.Value, | 24 Fecha = e.Fecha.HasValue ? e.Fecha.Value.ToShortDateString() : string.Empty, |
25 PuedeModificar = e.GetEstado().PuedePromover(Accion.Modificar), | 25 Estado = e.Estado, |
26 PuedeConfirmar = e.GetEstado().PuedePromover(Accion.Confirmar), | 26 PuedeAgendar = e.GetEstado().PuedePromover(Accion.Agendar), |
27 PuedePublicar = e.GetEstado().PuedePromover(Accion.Publicar) | 27 PuedeModificar = e.GetEstado().PuedePromover(Accion.Modificar), |
28 } | 28 PuedeConfirmar = e.GetEstado().PuedePromover(Accion.Confirmar), |
29 }; | 29 PuedePublicar = e.GetEstado().PuedePromover(Accion.Publicar) |
30 } | |
31 }; | |
30 return View(model); | 32 return View(model); |
31 } | 33 } |
32 | 34 |
33 [Authorize] | 35 [Authorize] |
34 public ActionResult New() | 36 public ActionResult Nuevo() |
35 { | 37 { |
36 return View(new EventoNewModel()); | 38 return View(new EventoNewModel()); |
37 } | 39 } |
38 | 40 |
39 [HttpPost] | 41 [HttpPost] |
40 [Authorize] | 42 [Authorize] |
41 public ActionResult New(EventoNewModel model) | 43 public ActionResult Nuevo(EventoNewModel model) |
42 { | 44 { |
43 if (ModelState.IsValid) | 45 if (ModelState.IsValid) |
44 { | 46 { |
45 var agenda = AgendaFactory.GetAgenda(); | 47 var agenda = AgendaFactory.GetAgenda(); |
46 | 48 |
55 } | 57 } |
56 return View(model); | 58 return View(model); |
57 } | 59 } |
58 | 60 |
59 [Authorize] | 61 [Authorize] |
60 public ActionResult Edit(string id) | 62 public ActionResult Confirmar(string id) |
61 { | |
62 var agenda = AgendaFactory.GetAgenda(); | |
63 var evento = agenda.GetEvento(new Guid(id)); | |
64 | |
65 var model = new EventoEditModel | |
66 { | |
67 Id = id, | |
68 Titulo = evento.Titulo, | |
69 Ponente = evento.Ponente != null ? evento.Ponente.Nombre : string.Empty, | |
70 Fecha = evento.Fecha, | |
71 UrlInvitacion = evento.UrlInvitacion | |
72 }; | |
73 return View(model); | |
74 } | |
75 | |
76 [Authorize] | |
77 public ActionResult Confirm(string id) | |
78 { | 63 { |
79 var agenda = AgendaFactory.GetAgenda(); | 64 var agenda = AgendaFactory.GetAgenda(); |
80 agenda.Confirmar(new Guid(id)); | 65 agenda.Confirmar(new Guid(id)); |
81 | 66 |
82 this.AddNotification("Evento confirmado"); | 67 this.AddNotification("Evento confirmado"); |
83 return RedirectToAction("Index"); | 68 return RedirectToAction("Index"); |
84 } | 69 } |
85 | 70 |
86 [Authorize] | 71 [Authorize] |
87 public ActionResult Publish(string id) | 72 public ActionResult Publicar(string id) |
88 { | 73 { |
89 var agenda = AgendaFactory.GetAgenda(); | 74 var agenda = AgendaFactory.GetAgenda(); |
90 agenda.Publicar(new Guid(id), 0, string.Empty); | 75 agenda.Publicar(new Guid(id), 0, string.Empty); |
91 | 76 |
92 this.AddNotification("Evento publicado"); | 77 this.AddNotification("Evento publicado"); |
93 return RedirectToAction("Index"); | 78 return RedirectToAction("Index"); |
94 } | 79 } |
95 | 80 |
81 [Authorize] | |
82 public ActionResult Modificar(string id) | |
83 { | |
84 var agenda = AgendaFactory.GetAgenda(); | |
85 var evento = agenda.GetEvento(new Guid(id)); | |
86 | |
87 var model = new EventoEditModel | |
88 { | |
89 Id = id, | |
90 Titulo = evento.Titulo, | |
91 Ponente = evento.Ponente != null ? evento.Ponente.Nombre : string.Empty, | |
92 Fecha = evento.Fecha, | |
93 UrlInvitacion = evento.UrlInvitacion | |
94 }; | |
95 return View(model); | |
96 } | |
97 | |
96 [HttpPost] | 98 [HttpPost] |
97 [Authorize] | 99 [Authorize] |
98 public ActionResult Edit(EventoEditModel model) | 100 public ActionResult Modificar(EventoEditModel model) |
99 { | 101 { |
100 if (ModelState.IsValid) | 102 if (ModelState.IsValid) |
101 { | 103 { |
102 var agenda = AgendaFactory.GetAgenda(); | 104 var agenda = AgendaFactory.GetAgenda(); |
103 | 105 |
109 } | 111 } |
110 ModelState.AddModelError("error", r.ToString()); | 112 ModelState.AddModelError("error", r.ToString()); |
111 } | 113 } |
112 return View(model); | 114 return View(model); |
113 } | 115 } |
116 | |
117 [Authorize] | |
118 public ActionResult Agendar(string id) | |
119 { | |
120 var agenda = AgendaFactory.GetAgenda(); | |
121 var evento = agenda.GetEvento(new Guid(id)); | |
122 | |
123 var model = new EventoAgendarModel | |
124 { | |
125 Id = id, | |
126 Titulo = evento.Titulo, | |
127 Ponente = evento.Ponente != null ? evento.Ponente.Nombre : string.Empty, | |
128 Fecha = evento.Fecha, | |
129 UrlInvitacion = evento.UrlInvitacion | |
130 }; | |
131 return View(model); | |
132 } | |
133 | |
134 [HttpPost] | |
135 [Authorize] | |
136 public ActionResult Agendar(EventoAgendarModel model) | |
137 { | |
138 if (ModelState.IsValid) | |
139 { | |
140 var agenda = AgendaFactory.GetAgenda(); | |
141 | |
142 var r = agenda.ModificarEvento(new Guid(model.Id), model.Titulo, model.Ponente, model.Fecha.Value, model.UrlInvitacion); | |
143 if (r.Succeful) | |
144 { | |
145 this.AddNotification("evento agendado"); | |
146 return RedirectToAction("Index"); | |
147 } | |
148 ModelState.AddModelError("error", r.ToString()); | |
149 } | |
150 return View(model); | |
151 } | |
152 | |
153 [Authorize] | |
154 public ActionResult Proponer() | |
155 { | |
156 return View(new PropuestaNewModel()); | |
157 } | |
158 | |
159 [HttpPost] | |
160 [Authorize] | |
161 public ActionResult Proponer(PropuestaNewModel model) | |
162 { | |
163 if (ModelState.IsValid) | |
164 { | |
165 var agenda = AgendaFactory.GetAgenda(); | |
166 | |
167 var r = agenda.Proponer(model.Titulo, model.Ponente, model.UrlInvitacion, (TipoEvento)model.Tipo); | |
168 if (r.Succeful) | |
169 return RedirectToAction("Index"); | |
170 ModelState.AddModelError("error", r.ToString()); | |
171 } | |
172 return View(model); | |
173 } | |
174 | |
114 } | 175 } |
115 } | 176 } |