public ActionResult Login(string user, string password) { string passEncrip = UsuarioController.HashSHA1(password); using (var db = new inventarioEntities1()) { var userLogin = db.usuario.FirstOrDefault(e => e.email == user && e.password == passEncrip); if (userLogin != null) { FormsAuthentication.SetAuthCookie(userLogin.email, true); Session["User"] = userLogin; return(RedirectToAction("index")); } else { return(Login("Verifique sus datos")); } } }
public ActionResult Create(usuario usuario) { if (!ModelState.IsValid) { return(View()); } try { using (var db = new inventarioEntities1()) { usuario.password = UsuarioController.HashSHA1(usuario.password); db.usuario.Add(usuario); _ = db.SaveChanges(); return(RedirectToAction("index")); } } catch (Exception ex) { ModelState.AddModelError("", "error " + ex); return(View()); } }