public async Task <ActionResult> Login(LoginModel model, string returnUrl) { LogRequest(); if (ModelState.IsValid) { //if (ReportHelper.CheckSoftwareExpiration()) //{ var entity = aspNetUserService.GetByEmail(model.UserName); if (entity != null) { var user = await userManager.FindAsync(model.UserName, model.Password); if (user != null) { await SignInAsync(user, model.RememberMe); var EmpInfo = officeExecutiveService.GetByEmail(model.UserName); if (EmpInfo != null) { #region Session Value SessionHelper.LoggedInUserFullName = EmpInfo.ExecutiveName; SessionHelper.LoggedInUserId = Convert.ToInt32(entity.UserId); SessionHelper.UserName = model.UserName; SessionHelper.LoggedInUserId_Hrm = EmpInfo.Id; SessionHelper.EmployeeCode = EmpInfo.ExecutiveCode; SessionHelper.LoggedInOfficeId = EmpInfo.OrganizationId; SessionHelper.LoggedIn_RoleId = entity.RoleId; SessionHelper.RoleName = roleService.GetById(entity.RoleId).Name; var organization = organizationService.GetById(EmpInfo.OrganizationId); var group = groupSetupService.GetById(organization.GroupId); SessionHelper.GroupName = group.GroupName; SessionHelper.GroupShortName = group.GroupName; SessionHelper.OrganizationLogo = group.GroupLogo; SessionHelper.OrganizationName = organization.OrganizationName; SessionHelper.OrganizationShortName = organization.OrganizationShortName; SessionHelper.OrganizationAddress = group.GroupAddress; SessionHelper.OrgEmail = organization.OrganizationEmail; SessionHelper.OrgEmailPassword = organization.OrganizationEmailPassword; SessionHelper.SMSPassword = group.SMSPassword; SessionHelper.SMSMobileNo = group.SMSMobileNo; SessionHelper.SMSUserName = group.SMSUserName; SessionHelper.OrganizationLogoPath = group.GroupLogo; SessionHelper.LoggedInOfficeName = organization.OrganizationName; SessionHelper.BusinessDate = sPService.GetBusinessDay().ToString("dd/MM/yyyy"); SessionHelper.TransactionDate = Convert.ToDateTime( ReportHelper.FormatDateToString(sPService.GetBusinessDay() .ToString("dd/MM/yyyy"))); sPService.GetDataBySqlCommand("USP_AUTO_RESERVE_UNLOCK"); SessionHelper.Areas = sPService.GetDataBySqlCommand( "SELECT DISTINCT AreaName FROM AspNetSecurityModule WHERE ISNULL(AreaName,'')<>'' AND IsActive=1") .Tables[0].AsEnumerable().Select(x => x.Field <string>(0)).ToList(); sPService.GetDataBySqlCommand("UPDATE ProductInformation SET ProductStatusId = 1 WHERE IsActive = 1 AND ProductStatusId = 3 AND CONVERT(DATE,ReservedUptoDate,106) = CONVERT(VARCHAR,'" + DateTime.Now + "',106)"); #endregion ReportSetting(); var Project = securityService.GetAllProject(SessionHelper.LoggedIn_RoleId, "0").ToList(); SessionHelper.UserprojectPermission(Project); if (Project.Count == 1) //he has one project permission { var ProjectName = Project.FirstOrDefault().ProjectShortName; var ReturnPage = ProjectWiseMenu(ProjectName); return(RedirectToAction(Project.FirstOrDefault().ProjectHomePage, "Home")); } return(RedirectToAction("Projects", "Home")); } else { return(RedirectToAction("UnauthorizedAccess", "Home")); } } else { ModelState.AddModelError("", "Invalid username or password."); } } else { ModelState.AddModelError("", "Invalid username or password."); } //} //else //{ // ModelState.AddModelError("", "Software has been expired due to payment issue. Please contact to your vendor."); //} } else { // If we got this far, something failed, redisplay form ModelState.AddModelError("", "The user name or password provided is incorrect."); } return(View(model)); }