private async Task <ApplicationIdentityUserModel> AssignValueToModel(ApplicationIdentityUser applicationIdentityUser) { return(await Task.Run(() => { ApplicationIdentityUserModel applicationIdentityUserModel = new ApplicationIdentityUserModel(); applicationIdentityUserModel.Id = applicationIdentityUser.Id; applicationIdentityUserModel.UserName = applicationIdentityUser.UserName; applicationIdentityUserModel.NormalizedUserName = applicationIdentityUser.NormalizedUserName; applicationIdentityUserModel.Email = applicationIdentityUser.Email; applicationIdentityUserModel.NormalizedEmail = applicationIdentityUser.NormalizedEmail; applicationIdentityUserModel.EmailConfirmed = applicationIdentityUser.EmailConfirmed; applicationIdentityUserModel.PasswordHash = applicationIdentityUser.PasswordHash; applicationIdentityUserModel.SecurityStamp = applicationIdentityUser.SecurityStamp; applicationIdentityUserModel.ConcurrencyStamp = applicationIdentityUser.ConcurrencyStamp; applicationIdentityUserModel.PhoneNumber = applicationIdentityUser.PhoneNumber; applicationIdentityUserModel.PhoneNumberConfirmed = applicationIdentityUser.PhoneNumberConfirmed; applicationIdentityUserModel.TwoFactorEnabled = applicationIdentityUser.TwoFactorEnabled; applicationIdentityUserModel.LockoutEnd = Convert.ToDateTime(applicationIdentityUser.LockoutEnd); applicationIdentityUserModel.LockoutEnabled = applicationIdentityUser.LockoutEnabled; applicationIdentityUserModel.AccessFailedCount = applicationIdentityUser.AccessFailedCount; return applicationIdentityUserModel; })); }
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 <ApplicationIdentityUserModel> GetApplicationIdentityUserListByEmail(string email) { ApplicationIdentityUserModel applicationIdentityUserModel = null; IList <ApplicationIdentityUserModel> applicationIdentityUserModelList = await GetApplicationIdentityUserList(0, email); if (null != applicationIdentityUserModelList && applicationIdentityUserModelList.Any()) { applicationIdentityUserModel = applicationIdentityUserModelList.FirstOrDefault(); } return(applicationIdentityUserModel); // returns. }
public async Task <ApplicationIdentityUserModel> GetApplicationIdentityUserListByUserId(int userId) { ApplicationIdentityUserModel applicationIdentityUserModel = null; IList <ApplicationIdentityUserModel> applicationIdentityUserModelList = await GetApplicationIdentityUserList(userId, ""); if (null != applicationIdentityUserModelList && applicationIdentityUserModelList.Any()) { applicationIdentityUserModel = applicationIdentityUserModelList.FirstOrDefault(); } return(applicationIdentityUserModel); // returns. }
public async Task <int> CreateUser(ApplicationIdentityUserModel applicationIdentityUserModel) { int userId = 0; // assign values. ApplicationIdentityUser applicationIdentityUser = new ApplicationIdentityUser(); //applicationIdentityUser.CurrencyCode = applicationIdentityUserModel.CurrencyCode; //applicationIdentityUser.CurrencyName = applicationIdentityUserModel.CurrencyName; //applicationIdentityUser.Denomination = applicationIdentityUserModel.Denomination; userId = await Create(applicationIdentityUser); return(userId); // returns. }