diff Agendas/trunk/src/Agendas.Web/Controllers/PersonaApiController.cs @ 219:b9850b647a4e

Agregando alta de ponente durante la carga del evento
author nelopauselli
date Thu, 08 Sep 2011 11:22:10 -0300
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Agendas/trunk/src/Agendas.Web/Controllers/PersonaApiController.cs	Thu Sep 08 11:22:10 2011 -0300
@@ -0,0 +1,32 @@
+using System;
+using System.Web.Mvc;
+using AltNetHispano.Agendas.Domain;
+using AltNetHispano.Agendas.Factories;
+using AltNetHispano.Agendas.Web.Models;
+
+namespace AltNetHispano.Agendas.Web.Controllers
+{
+	public class PersonaApiController : Controller
+	{
+		[CustomAuthorize(Roles = Roles.Administrador)]
+		public PartialViewResult Nueva()
+		{
+			var model = new PersonaNewModel();
+			return PartialView(model);
+		}
+
+		[HttpPost]
+		[CustomAuthorize(Roles = Roles.Administrador)]
+		public JsonResult Nueva(PersonaNewModel model)
+		{
+			if (ModelState.IsValid)
+			{
+				var personas = AgendaFactory.GetPersonaService();
+				var r = personas.Add(model.Nombre, model.Twitter, model.EMail, model.Blog, model.Roles);
+				return Json(r);
+			}
+
+			return Json(new Resultado(false, string.Join(",", ModelState.Values)));
+		}
+	}
+}
\ No newline at end of file