view Agendas/trunk/src/Agendas.Web/Controllers/PersonaApiController.cs @ 254:478656b70afb

Tag deploy 2011-10-07 v1.0.3 para conjunto de cambios 7cf64cd790ab añadido
author Administrador@DESA-WIN-002.cpe.telecentro.net.ar
date Mon, 17 Oct 2011 07:41:32 -0300
parents b9850b647a4e
children
line wrap: on
line source

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)));
		}
	}
}