Ejemplo n.º 1
0
        public ActionResult Login(FormCollection form, bool rememberMe = false)
        {
            String email    = form["Email address"].ToString();
            String password = form["Password"].ToString();

            NWLDataContext db = new NWLDataContext();

            bool exists = db.users.Any(x => x.Email == email && x.Password == password);

            if (!exists)
            {
                return(View("LoginFail"));
            }

            var item = db.users.Where(x => x.Email == email && x.Password == password).First();


            if (item.RoleID != RoleType)
            {
                return(View("LoginUnauthorized"));
            }

            FormsAuthentication.SetAuthCookie(email, rememberMe);

            if (RoleType == 1)
            {
                return(RedirectToAction("Index", "Customer", new { userLogin = item.UserID }));
            }
            else if (RoleType == 2)
            {
                return(RedirectToAction("Index", "Singapore", new { userLogin = item.UserID }));
            }
            else if (RoleType == 3)
            {
                return(RedirectToAction("Index", "Seattle", new { userLogin = item.UserID }));
            }
            else
            {
                return(View("LoginFail"));
            }
        }