public async Task <IActionResult> Login(LoginViewModel user) { if (ModelState.IsValid) { var result = await _signInManager.PasswordSignInAsync(user.Email, user.Password, user.RememberMe, false); if (result.Succeeded) { ApplicationIdentityUserModel applicationUser = await _aplicationIdentityUser.GetApplicationIdentityUserListByEmail(user.Email); UserSessionModel userSessionModel = new UserSessionModel(); userSessionModel.UserId = applicationUser.Id; userSessionModel.UserName = applicationUser.UserName; //start temporary avoid branch/financial year selection userSessionModel.CompanyId = 1; userSessionModel.FinancialYearId = 1; //temporary avoid branch/financial year selection SessionExtension.SetComplexData(HttpContext.Session, "UserSession", userSessionModel); return(RedirectToAction("Index", "Home", new { area = "Common" })); } ModelState.AddModelError(string.Empty, "Invalid Login Attempt"); } return(View(user)); }
public async Task <JsonResult> ChooseCommpany(int companyId) { JsonData <JsonStatus> data = new JsonData <JsonStatus>(new JsonStatus()); return(await Task.Run(() => { UserSessionModel userSessionModel = SessionExtension.GetComplexData <UserSessionModel>(HttpContext.Session, "UserSession"); userSessionModel.CompanyId = companyId; SessionExtension.SetComplexData(HttpContext.Session, "UserSession", userSessionModel); return Json(data); })); }