public ActionResult Login(string email = "", string password = "") { if (Request.HttpMethod == "GET") { return(View()); } else { var newUser = AccountBLL.Account_Login(email, password); if (newUser != null) { Account account = AccountBLL.Account_Login(email, password); FormsAuthentication.SetAuthCookie(account.AccountID.ToString(), false); HttpCookie userInfo = new HttpCookie("userInfo"); userInfo["AccountID"] = account.AccountID.ToString(); userInfo["FullName"] = Server.UrlEncode(account.LastName + " " + account.FirstName); userInfo["Email"] = account.Email; userInfo["PhotoPath"] = account.PhotoPath; userInfo.Expires = DateTime.Now.AddDays(1); Response.Cookies.Add(userInfo); return(RedirectToAction("Index", "Dashboard")); } else { ModelState.AddModelError("error", "Đăng nhập thất bại"); ViewBag.email = email; return(View()); } } }