Ejemplo n.º 1
0
        public ActionResult Login(UserVM person)
        {
            var usr = humanLg.Login(person.userName, person.userPassword);

            if (usr != null)
            {
                Session["UserID"]   = usr.userID;
                Session["UserName"] = usr.userName;
                Session["Position"] = usr.userPosition;
                ViewBag.Message     = person.userName;

                if (usr.userPosition == "Admin" || usr.userPosition == "admin")
                {
                    Session["Admin"] = new UserVM();
                    return(RedirectToAction("DisplayAdmin"));
                }
                else if (usr.userPosition == "Employee" || usr.userPosition == "employee")
                {
                    return(RedirectToAction("DisplayEmployee"));
                }
                else if (usr.userPosition == "Customer" || usr.userPosition == "customer")
                {
                    Session["Customer"] = new UserVM();
                    return(RedirectToAction("DisplayCustomer"));
                }
                else
                {
                    ModelState.AddModelError("", "Incorrect UserName or Password");
                }
            }
            else
            {
                return(RedirectToAction("Login", "Index"));
            }
            return(View());
        }