public ActionResult Index(Usuario model) { var srv = new BaseServicios <Usuario>("http://localhost:49322/api/Usuarios"); var param = new Dictionary <String, Object>() { { "login", model.login }, { "password", model.password } }; var u = srv.Get(param); if (u != null) { var identity = new GenericIdentity(u.nombre); var provider = new GenericPrincipal(identity, new string[] {}); HttpContext.User = provider; Session["usuario"] = u; } else { return(View(model)); } return(RedirectToAction("Index", "Home")); }
public async Task <ActionResult> Registro(Usuario model) { var srv = new BaseServicios <Usuario>("http://localhost:49322/api/Usuarios"); try { await srv.Add(model); } catch (Exception e) { return(View(model)); } return(RedirectToAction("Index")); }