Mercurial > altnet-hispano
annotate 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 |
rev | line source |
---|---|
25
e8d2be47a6b0
Cambios de nombre en Portal.Web (Agenda x Evento)
nelo@MTEySS.neluz.int
parents:
diff
changeset
|
1 using System; |
e8d2be47a6b0
Cambios de nombre en Portal.Web (Agenda x Evento)
nelo@MTEySS.neluz.int
parents:
diff
changeset
|
2 using System.Linq; |
e8d2be47a6b0
Cambios de nombre en Portal.Web (Agenda x Evento)
nelo@MTEySS.neluz.int
parents:
diff
changeset
|
3 using System.Web.Mvc; |
106
80c22175c9b5
agregado de tipo de evento (van, cafe, grupoestudio)
jorge.rowies
parents:
97
diff
changeset
|
4 using AltNetHispano.Agendas.Domain; |
34
475be11edf56
Ajuste en los nombre de los assemblies y namespaces
nelo@MTEySS.neluz.int
parents:
27
diff
changeset
|
5 using AltNetHispano.Agendas.Factories; |
475be11edf56
Ajuste en los nombre de los assemblies y namespaces
nelo@MTEySS.neluz.int
parents:
27
diff
changeset
|
6 using AltNetHispano.Agendas.Web.Models; |
25
e8d2be47a6b0
Cambios de nombre en Portal.Web (Agenda x Evento)
nelo@MTEySS.neluz.int
parents:
diff
changeset
|
7 |
34
475be11edf56
Ajuste en los nombre de los assemblies y namespaces
nelo@MTEySS.neluz.int
parents:
27
diff
changeset
|
8 namespace AltNetHispano.Agendas.Web.Controllers |
25
e8d2be47a6b0
Cambios de nombre en Portal.Web (Agenda x Evento)
nelo@MTEySS.neluz.int
parents:
diff
changeset
|
9 { |
117 | 10 public class EventoController : Controller |
11 { | |
12 public ActionResult Index() | |
13 { | |
14 var agenda = AgendaFactory.GetAgenda(); | |
106
80c22175c9b5
agregado de tipo de evento (van, cafe, grupoestudio)
jorge.rowies
parents:
97
diff
changeset
|
15 |
117 | 16 var model = new EventoIndexModel |
118 | 17 { |
18 ProximosEventos = from e in agenda.GetEventosActivos() | |
19 orderby e.Fecha | |
20 select new EventoDto | |
21 { | |
22 Id = e.Id.ToString(), | |
23 Titulo = e.Titulo, | |
24 Fecha = e.Fecha.HasValue ? e.Fecha.Value.ToShortDateString() : string.Empty, | |
25 Estado = e.Estado, | |
26 PuedeAgendar = e.GetEstado().PuedePromover(Accion.Agendar), | |
27 PuedeModificar = e.GetEstado().PuedePromover(Accion.Modificar), | |
28 PuedeConfirmar = e.GetEstado().PuedePromover(Accion.Confirmar), | |
29 PuedePublicar = e.GetEstado().PuedePromover(Accion.Publicar) | |
30 } | |
31 }; | |
117 | 32 return View(model); |
33 } | |
25
e8d2be47a6b0
Cambios de nombre en Portal.Web (Agenda x Evento)
nelo@MTEySS.neluz.int
parents:
diff
changeset
|
34 |
117 | 35 [Authorize] |
118 | 36 public ActionResult Nuevo() |
117 | 37 { |
38 return View(new EventoNewModel()); | |
39 } | |
25
e8d2be47a6b0
Cambios de nombre en Portal.Web (Agenda x Evento)
nelo@MTEySS.neluz.int
parents:
diff
changeset
|
40 |
117 | 41 [HttpPost] |
42 [Authorize] | |
118 | 43 public ActionResult Nuevo(EventoNewModel model) |
117 | 44 { |
45 if (ModelState.IsValid) | |
46 { | |
47 var agenda = AgendaFactory.GetAgenda(); | |
25
e8d2be47a6b0
Cambios de nombre en Portal.Web (Agenda x Evento)
nelo@MTEySS.neluz.int
parents:
diff
changeset
|
48 |
117 | 49 var r = agenda.Agendar(model.Titulo, model.Ponente, model.Fecha, |
50 model.UrlInvitacion, (TipoEvento)model.Tipo); | |
51 if (r.Succeful) | |
52 { | |
53 this.AddNotification("Datos guardados"); | |
54 return RedirectToAction("Index"); | |
55 } | |
56 ModelState.AddModelError("error", r.ToString()); | |
57 } | |
58 return View(model); | |
59 } | |
25
e8d2be47a6b0
Cambios de nombre en Portal.Web (Agenda x Evento)
nelo@MTEySS.neluz.int
parents:
diff
changeset
|
60 |
117 | 61 [Authorize] |
118 | 62 public ActionResult Confirmar(string id) |
117 | 63 { |
64 var agenda = AgendaFactory.GetAgenda(); | |
65 agenda.Confirmar(new Guid(id)); | |
66 | |
67 this.AddNotification("Evento confirmado"); | |
68 return RedirectToAction("Index"); | |
69 } | |
116
53bcd338542b
acciones de confirmar y publicar desde la UI
Nelo@Kenia.neluz.int
parents:
106
diff
changeset
|
70 |
117 | 71 [Authorize] |
118 | 72 public ActionResult Publicar(string id) |
117 | 73 { |
74 var agenda = AgendaFactory.GetAgenda(); | |
75 agenda.Publicar(new Guid(id), 0, string.Empty); | |
76 | |
77 this.AddNotification("Evento publicado"); | |
78 return RedirectToAction("Index"); | |
79 } | |
116
53bcd338542b
acciones de confirmar y publicar desde la UI
Nelo@Kenia.neluz.int
parents:
106
diff
changeset
|
80 |
118 | 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 | |
117 | 98 [HttpPost] |
99 [Authorize] | |
118 | 100 public ActionResult Modificar(EventoEditModel model) |
117 | 101 { |
102 if (ModelState.IsValid) | |
103 { | |
104 var agenda = AgendaFactory.GetAgenda(); | |
25
e8d2be47a6b0
Cambios de nombre en Portal.Web (Agenda x Evento)
nelo@MTEySS.neluz.int
parents:
diff
changeset
|
105 |
117 | 106 var r = agenda.ModificarEvento(new Guid(model.Id), model.Titulo, model.Ponente, model.Fecha.Value, model.UrlInvitacion); |
107 if (r.Succeful) | |
108 { | |
109 this.AddNotification("datos guardados"); | |
110 return RedirectToAction("Index"); | |
111 } | |
112 ModelState.AddModelError("error", r.ToString()); | |
113 } | |
114 return View(model); | |
115 } | |
118 | 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 | |
117 | 175 } |
25
e8d2be47a6b0
Cambios de nombre en Portal.Web (Agenda x Evento)
nelo@MTEySS.neluz.int
parents:
diff
changeset
|
176 } |