public ActionResult login(string email, string matkhau) { var dal = new CUSTOMERDAL(); var getpwd = dal.getpasswordbyemail(email); if (getpwd == null) { ModelState.AddModelError("", "Sai email! Vui lòng kiểm tra lại"); } else { if ((MD5Encryptor.MD5Hash(matkhau)).Equals(getpwd)) { var customer = dal.getuserbyemail(email); var cSession = new customerlogin(); cSession.MACUSTOMER = customer.MACUSTOMER; cSession.TENCUSTOMER = customer.TENCUSTOMER; cSession.EMAIL = customer.EMAIL; cSession.DIACHI = customer.DIACHI; cSession.MATKHAU = matkhau; cSession.NGAYSINH = customer.NGAYSINH; cSession.RATING = customer.RATING; cSession.SDT = customer.SDT; Session.Add(constant.CUSTOMER_SESSION, cSession); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Sai mật khẩu"); } } return(View()); }
public ActionResult CustomerLogin(customerlogin cl) { User u = new User(); u.UserEmail = cl.Email; u.UserPwd = cl.Password; int choice = d.UserValidate(u); switch (choice) { case 1: //for user does not exist ; Session["error"] = "User does not exist"; break; case 2: //for user's email or password is incorrect ; Session["error"] = "Incorrect Password or Email please try again"; break; case 3: Session["error"] = "Your account has not been activated, please check your email"; //for user's not activating link break; case 5: Session["error"] = "User is inactive.....contact Admin Thanks."; //for user's not activating link break; default: Session["CustomerID"] = u.userId; return(RedirectToAction("Index", "CustomerService")); } return(RedirectToAction("CustomerLogin")); }