예제 #1
0
        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"));
        }
예제 #2
0
        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"));
        }