comparison Agendas/trunk/src/Agendas.Web/Controllers/AgendaController.cs @ 19:74eb4577d447

HttpContext identity provider Requerimiento de autenticación para registrar un nuevo evento o modificar uno existente
author nelo@MTEySS.neluz.int
date Mon, 14 Mar 2011 00:35:43 -0300
parents 08b9e96132a5
children 41b283d27e3e
comparison
equal deleted inserted replaced
18:8ed4a806ebe0 19:74eb4577d447
1 using System; 1 using System;
2 using System.Collections.Generic;
3 using System.Linq; 2 using System.Linq;
4 using System.Web.Mvc; 3 using System.Web.Mvc;
5 using Agendas.Factories; 4 using Agendas.Factories;
6 using Agendas.Web.Models; 5 using Agendas.Web.Models;
7 using AltNetHispano.Agendas.Domain;
8 using AltNetHispano.Agendas.Domain.Exceptions; 6 using AltNetHispano.Agendas.Domain.Exceptions;
9 7
10 namespace Agendas.Web.Controllers 8 namespace Agendas.Web.Controllers
11 { 9 {
12 public class AgendaController : Controller 10 public class AgendaController : Controller
26 ProximosEventos = from e in agenda.GetEventosPublicados() 24 ProximosEventos = from e in agenda.GetEventosPublicados()
27 select new EventoDto {Id = e.Id.ToString(), Titulo = e.Titulo} 25 select new EventoDto {Id = e.Id.ToString(), Titulo = e.Titulo}
28 }; 26 };
29 } 27 }
30 28
31 public ActionResult New() 29 [Authorize]
30 public ActionResult New()
32 { 31 {
33 return View(); 32 return View();
34 } 33 }
35 34
36 [HttpPost] 35 [HttpPost]
37 public ActionResult New(AgendaNewModel model) 36 [Authorize]
37 public ActionResult New(AgendaNewModel model)
38 { 38 {
39 if (ModelState.IsValid) 39 if (ModelState.IsValid)
40 { 40 {
41 var agenda = AgendaFactory.GetAgenda(); 41 var agenda = AgendaFactory.GetAgenda();
42 42
52 } 52 }
53 } 53 }
54 return View(model); 54 return View(model);
55 } 55 }
56 56
57 [Authorize]
57 public ActionResult Edit(string id) 58 public ActionResult Edit(string id)
58 { 59 {
59 var agenda = AgendaFactory.GetAgenda(); 60 var agenda = AgendaFactory.GetAgenda();
60 var evento = agenda.GetEventoPublicado(new Guid(id)); 61 var evento = agenda.GetEventoPublicado(new Guid(id));
61 if (evento!=null) 62 if (evento!=null)
66 ModelState.AddModelError("error","No se encontró el evento que quiere modificar"); 67 ModelState.AddModelError("error","No se encontró el evento que quiere modificar");
67 return View(); 68 return View();
68 } 69 }
69 70
70 [HttpPost] 71 [HttpPost]
72 [Authorize]
71 public ActionResult Edit(AgendaEditModel model) 73 public ActionResult Edit(AgendaEditModel model)
72 { 74 {
73 if (ModelState.IsValid) 75 if (ModelState.IsValid)
74 { 76 {
75 var agenda = AgendaFactory.GetAgenda(); 77 var agenda = AgendaFactory.GetAgenda();