public ActionResult Index(DeclarationViewModel model) { session.Set("LastSubmittedPageSection", "Index"); session.Set("LastSubmittedPageId", "Declaration"); if (!ModelState.IsValid) { return(View("Index", model)); } licenceApplicationPostDataHandler.Update(session.GetCurrentLicenceId(), x => x, model); return(RedirectToAction("TaskList", "Licence")); }
public async Task <IActionResult> LoginAsync(string returnUrl, LoginModel model) { try { if (ModelState.IsValid) { //hash password var password = Crypto.HashPassword(model.Password); var user = await _userService.LoginAsync(model.Email, password); if (user != null && user.Status == (int)UserStatus.Active) { await _userService.UpdateLastLoginDateAsync(user.Email); _sessionHelper.SetString(SessionKey.CurrentUserId, user.Id.ToString()); _sessionHelper.Set(SessionKey.CurrentUser, user); _sessionHelper.Set(SessionKey.CurrentRole, await _roleService.GetByIdAsync(user.RoleId)); var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme); identity.AddClaim(new Claim(ClaimTypes.Name, model.Email)); var principle = new ClaimsPrincipal(identity); var properties = new AuthenticationProperties { IsPersistent = model.RememberMe }; await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principle, properties); if (!string.IsNullOrEmpty(returnUrl) && returnUrl.ToLowerInvariant().Contains("logout")) { returnUrl = "/admin"; } return(LocalRedirect(returnUrl ?? "/admin")); } } SetTitle("Đăng nhập", "login"); ViewData["ReturnUrl"] = returnUrl; ModelState.AddModelError(string.Empty, "Email hoặc Mật khẩu không chính xác."); return(View("Login", model)); } catch (Exception ex) { Log.Fatal(ex, "AccountController > LoginAsync"); return(NotFound()); } }
public IActionResult Index(PublicRegisterLicenceListViewModel publicRegisterLicenceListViewModel, string submitButtonType) { SessionHelper.Set("publicRegisterSearchCriteria", publicRegisterLicenceListViewModel.PublicRegisterSearchCriteria); SessionHelper.SetString("publicRegisterSearchCriteria_submitButtonType", submitButtonType); return(RedirectToAction("Index")); }
public ActionResult Part1(SuppliesWorkersViewModel model) { session.Set("LastSubmittedPageSection", "Part1"); session.Set("LastSubmittedPageId", 1); if (!ModelState.IsValid) { return(View("Eligibility.1", model)); } licenceApplicationPostDataHandler.Update(session.GetCurrentLicenceId(), x => x, model); return(RedirectToAction($"Part/2")); }