예제 #1
0
        public ActionResult Login(string email, string password)
        {
            string passEncrip = UsuarioController.HashSHA1(password);

            using (var db = new inventario2021Entities())
            {
                var userLogin = db.usuario.FirstOrDefault(e => e.email == email && e.password == passEncrip);
                if (userLogin != null)
                {
                    FormsAuthentication.SetAuthCookie(userLogin.email, true);
                    Session["User"] = userLogin;
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(Login("Verifique sus Datos"));
                }
            }
        }
예제 #2
0
        public ActionResult Create(usuario usuario)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try {
                using (var db = new inventario2021Entities())
                {
                    usuario.password = UsuarioController.HashSHA1(usuario.password);
                    db.usuario.Add(usuario);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }catch (Exception ex)
            {
                ModelState.AddModelError("", "error" + ex);
                return(View());
            }
        }