Example #1
0
        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());
        }
Example #2
0
 public Store()
 {
     dbContext = new HimiyaDbContext();
 }