Пример #1
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                var user = _db.Admins.FirstOrDefault(item => item.Name == model.Name && item.Password == model.Password);
                if (user != null)
                {
                    Session["user"] = new MainUser()
                    {
                        Id = user.Id,
                        Name = user.Name,
                        LastName = user.LastName,
                        Category = user.AdminCategoryId
                    };
                    return RedirectToAction("Index", "Home");
                }
            }

            return View(model);
        }
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                var user = _db.Operators.FirstOrDefault(item => item.Name == model.Name && item.Password == model.Password);
                if (user != null)
                {
                    LoginHelper.CreateUser(new MainUser()
                    {
                        Id = user.OperatorID,
                        Name = user.Name,
                        LastName = user.Lastname,
                        Category = user.CategoryID
                    });
                    return RedirectToAction("create", "orders");
                }
            }

            return View(model);
        }