Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.Web/Controllers/EventoController.cs @ 117:7ef7e4bb71f6
manejo de mensajes al usuario
author | Nelo@Kenia.neluz.int |
---|---|
date | Sun, 19 Jun 2011 13:35:34 -0300 |
parents | 53bcd338542b |
children | b74734a1a755 |
comparison
equal
deleted
inserted
replaced
116:53bcd338542b | 117:7ef7e4bb71f6 |
---|---|
5 using AltNetHispano.Agendas.Factories; | 5 using AltNetHispano.Agendas.Factories; |
6 using AltNetHispano.Agendas.Web.Models; | 6 using AltNetHispano.Agendas.Web.Models; |
7 | 7 |
8 namespace AltNetHispano.Agendas.Web.Controllers | 8 namespace AltNetHispano.Agendas.Web.Controllers |
9 { | 9 { |
10 public class EventoController : Controller | 10 public class EventoController : Controller |
11 { | 11 { |
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 { | |
18 ProximosEventos = from e in agenda.GetEventosAgendados() | |
19 orderby e.Fecha | |
20 select new EventoDto | |
21 { | 17 { |
22 Id = e.Id.ToString(), | 18 ProximosEventos = from e in agenda.GetEventosAgendados() |
23 Titulo = e.Titulo, | 19 orderby e.Fecha |
24 Fecha = e.Fecha.Value, | 20 select new EventoDto |
25 PuedeModificar = e.GetEstado().PuedePromover(Accion.Modificar), | 21 { |
26 PuedeConfirmar = e.GetEstado().PuedePromover(Accion.Confirmar), | 22 Id = e.Id.ToString(), |
27 PuedePublicar = e.GetEstado().PuedePromover(Accion.Publicar) | 23 Titulo = e.Titulo, |
28 } | 24 Fecha = e.Fecha.Value, |
29 }; | 25 PuedeModificar = e.GetEstado().PuedePromover(Accion.Modificar), |
26 PuedeConfirmar = e.GetEstado().PuedePromover(Accion.Confirmar), | |
27 PuedePublicar = e.GetEstado().PuedePromover(Accion.Publicar) | |
28 } | |
29 }; | |
30 return View(model); | |
31 } | |
30 | 32 |
31 return View(model); | 33 [Authorize] |
32 } | 34 public ActionResult New() |
35 { | |
36 return View(new EventoNewModel()); | |
37 } | |
33 | 38 |
34 [Authorize] | 39 [HttpPost] |
35 public ActionResult New() | 40 [Authorize] |
36 { | 41 public ActionResult New(EventoNewModel model) |
37 return View(new EventoNewModel()); | 42 { |
38 } | 43 if (ModelState.IsValid) |
44 { | |
45 var agenda = AgendaFactory.GetAgenda(); | |
39 | 46 |
40 [HttpPost] | 47 var r = agenda.Agendar(model.Titulo, model.Ponente, model.Fecha, |
41 [Authorize] | 48 model.UrlInvitacion, (TipoEvento)model.Tipo); |
42 public ActionResult New(EventoNewModel model) | 49 if (r.Succeful) |
43 { | 50 { |
44 if (ModelState.IsValid) | 51 this.AddNotification("Datos guardados"); |
45 { | 52 return RedirectToAction("Index"); |
46 var agenda = AgendaFactory.GetAgenda(); | 53 } |
54 ModelState.AddModelError("error", r.ToString()); | |
55 } | |
56 return View(model); | |
57 } | |
47 | 58 |
48 var r = agenda.Agendar(model.Titulo, model.Ponente, model.Fecha, | 59 [Authorize] |
49 model.UrlInvitacion, (TipoEvento)model.Tipo); | 60 public ActionResult Edit(string id) |
50 if (r.Succeful) | 61 { |
51 return RedirectToAction("Index"); | 62 var agenda = AgendaFactory.GetAgenda(); |
52 ModelState.AddModelError("error", r.ToString()); | 63 var evento = agenda.GetEvento(new Guid(id)); |
53 } | |
54 return View(model); | |
55 } | |
56 | 64 |
57 [Authorize] | 65 var model = new EventoEditModel |
58 public ActionResult Edit(string id) | 66 { |
59 { | 67 Id = id, |
60 var agenda = AgendaFactory.GetAgenda(); | 68 Titulo = evento.Titulo, |
61 var evento = agenda.GetEvento(new Guid(id)); | 69 Ponente = evento.Ponente != null ? evento.Ponente.Nombre : string.Empty, |
70 Fecha = evento.Fecha, | |
71 UrlInvitacion = evento.UrlInvitacion | |
72 }; | |
73 return View(model); | |
74 } | |
62 | 75 |
63 var model = new EventoEditModel | 76 [Authorize] |
64 { | 77 public ActionResult Confirm(string id) |
65 Id = id, | 78 { |
66 Titulo = evento.Titulo, | 79 var agenda = AgendaFactory.GetAgenda(); |
67 Ponente = evento.Ponente != null ? evento.Ponente.Nombre : string.Empty, | 80 agenda.Confirmar(new Guid(id)); |
68 Fecha = evento.Fecha, | |
69 UrlInvitacion = evento.UrlInvitacion | |
70 }; | |
71 return View(model); | |
72 } | |
73 | 81 |
74 [Authorize] | 82 this.AddNotification("Evento confirmado"); |
75 public ActionResult Confirm(string id) | 83 return RedirectToAction("Index"); |
76 { | 84 } |
77 var agenda = AgendaFactory.GetAgenda(); | 85 |
78 agenda.Confirmar(new Guid(id)); | 86 [Authorize] |
79 return RedirectToAction("Index"); | 87 public ActionResult Publish(string id) |
88 { | |
89 var agenda = AgendaFactory.GetAgenda(); | |
90 agenda.Publicar(new Guid(id), 0, string.Empty); | |
91 | |
92 this.AddNotification("Evento publicado"); | |
93 return RedirectToAction("Index"); | |
94 } | |
95 | |
96 [HttpPost] | |
97 [Authorize] | |
98 public ActionResult Edit(EventoEditModel model) | |
99 { | |
100 if (ModelState.IsValid) | |
101 { | |
102 var agenda = AgendaFactory.GetAgenda(); | |
103 | |
104 var r = agenda.ModificarEvento(new Guid(model.Id), model.Titulo, model.Ponente, model.Fecha.Value, model.UrlInvitacion); | |
105 if (r.Succeful) | |
106 { | |
107 this.AddNotification("datos guardados"); | |
108 return RedirectToAction("Index"); | |
109 } | |
110 ModelState.AddModelError("error", r.ToString()); | |
111 } | |
112 return View(model); | |
113 } | |
80 } | 114 } |
81 | |
82 [Authorize] | |
83 public ActionResult Publish(string id) | |
84 { | |
85 var agenda = AgendaFactory.GetAgenda(); | |
86 agenda.Publicar(new Guid(id), 0, string.Empty); | |
87 return RedirectToAction("Index"); | |
88 } | |
89 | |
90 [HttpPost] | |
91 [Authorize] | |
92 public ActionResult Edit(EventoEditModel model) | |
93 { | |
94 if (ModelState.IsValid) | |
95 { | |
96 var agenda = AgendaFactory.GetAgenda(); | |
97 | |
98 var r = agenda.ModificarEvento(new Guid(model.Id), model.Titulo, model.Ponente, model.Fecha.Value, model.UrlInvitacion); | |
99 if (r.Succeful) | |
100 return RedirectToAction("Index"); | |
101 ModelState.AddModelError("error", r.ToString()); | |
102 } | |
103 return View(model); | |
104 } | |
105 } | |
106 } | 115 } |