public ActionResult Login(string login, string password) { if (login == null) { throw new Exception(); } User user = null; using (HimiyaDbContext db = new HimiyaDbContext()) { user = db.Users.FirstOrDefault(u => u.Login == login); if (user != null && user.Password == password) { FormsAuthentication.SetAuthCookie(user.Login, true); return(RedirectToAction("Index", "Admin")); } else { ModelState.AddModelError("", "Невірний логін або пароль"); } } return(View()); }
public Store() { dbContext = new HimiyaDbContext(); }