public void RegisterEmployee(EmployeeRegistrationInfo _employeeRegInfo) { Data.EmployeeInfo _employee = _context.EmployeeInfoes.Find(_employeeRegInfo.EmployeeInfoId); if (_employee != null) { _employee.FirstName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(_employeeRegInfo.FirstName.ToLower()); _employee.LastName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(_employeeRegInfo.LastName.ToLower()); _employee.FatherName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(_employeeRegInfo.FatherName.ToLower()); _employee.DateOfBirth = _employeeRegInfo.DateOfBirth; _employee.CellNumber = _employeeRegInfo.CellNumber; _employee.ResidencePhoneNumber = _employeeRegInfo.ResidencePhoneNumber; _employee.MaritalStatus = _employeeRegInfo.MaritalStatus; _employee.PersonalEmail = _employeeRegInfo.PersonalEmail.ToLower(); _employee.CNIC = _employeeRegInfo.CNIC; _employee.PermanentAddress = _employeeRegInfo.PermanentAddress; _employee.PresentAddress = _employeeRegInfo.PresentAddress; _employee.TotalExperience = _employeeRegInfo.ExperienceYears + "," + _employeeRegInfo.ExperienceMonths; _employee.DateOfJoin = _employeeRegInfo.DateOfJoin; _context.SaveChanges(); } else { throw new ArgumentNullException(); } }
public ActionResult PersonalInfo(EmployeeRegistrationInfo _employeeRegInfo) { try { AuthenticatedUser _authUser; if (!ModelState.IsValid) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later."); return(RedirectToAction("PersonalInfo", "Profile")); } using (AuthRepository Repo = new AuthRepository()) { _authUser = Repo.GetAuthenticatedUserById(CurrentUser.EmployeeInfoId); } if (_authUser.IsFirstTimeLogin == true) { return(RedirectToAction("ResetPassword", "Account")); } if (_authUser.IsCheckListCompleted == true) { return(RedirectToAction("Logout", "Auth", new { area = "" })); } _employeeRegInfo.EmployeeInfoId = CurrentUser.EmployeeInfoId; using (var transaction = new System.Transactions.TransactionScope()) { using (FamilyMemberRepository Repo = new FamilyMemberRepository()) { var _familyMembersList = Repo.GetFamilyMembersListByEmployeeId(CurrentUser.EmployeeInfoId); if (_employeeRegInfo.MaritalStatus == "Single" && _familyMembersList.Count() > 0) { foreach (var item in _familyMembersList) { Repo.DeleteFamilyMember(item.Id); } } } using (EmployeeRepository Repo = new EmployeeRepository()) { Repo.RegisterEmployee(_employeeRegInfo); } using (AccountCheckListRepository Repo = new AccountCheckListRepository()) { var _accountCheckList = new AccountCheckListInfo(); _accountCheckList.IsPersonalInfoProvided = true; _accountCheckList.AccountId = CurrentUser.AccountId; Repo.UpdateIsPersonalInfoProvided(_accountCheckList); } transaction.Complete(); } if (_employeeRegInfo.MaritalStatus == "Married") { return(RedirectToAction("Details", "Family")); } else { return(RedirectToAction("UploadDocuments", "File")); } } catch (Exception ex) { TempData["Msg"] = AlertMessageProvider.FailureMessage(ex.ToString()); return(View()); } }
public ActionResult CheckListCompleted() { try { AuthenticatedUser _authUser; AccountCheckListInfo _accountCheckList; var _employeeRegInfo = new EmployeeRegistrationInfo(); using (AuthRepository Repo = new AuthRepository()) { _authUser = Repo.GetAuthenticatedUserById(CurrentUser.EmployeeInfoId); } if (_authUser.IsCheckListCompleted == true) { return(RedirectToAction("Logout", "Auth", new { area = "" })); } using (AccountCheckListRepository Repo = new AccountCheckListRepository()) { _accountCheckList = Repo.GetAccountCheckListByUserId(CurrentUser.AccountId); } if (_accountCheckList.IsPictureUploaded == false) { return(RedirectToAction("UploadPicture", "File")); } using (EmployeeRepository Repo = new EmployeeRepository()) { _employeeRegInfo = Repo.GetRegisterEmployeeInfoById(CurrentUser.EmployeeInfoId); _employeeRegInfo.DateOfJoin = DateTime.Now; Repo.RegisterEmployee(_employeeRegInfo); } using (AccountRepository Repo = new AccountRepository()) { Repo.CheckListCompleted(CurrentUser.AccountId); } using (AuthRepository Repo = new AuthRepository()) { _authUser = Repo.GetAuthenticatedUserById(CurrentUser.EmployeeInfoId); } var _authManager = HttpContext.GetOwinContext().Authentication; var _identity = new ClaimsIdentity(User.Identity); _identity.RemoveClaim(_identity.FindFirst(ClaimTypes.Role)); _identity.AddClaim(new Claim(ClaimTypes.Role, _authUser.Role)); _identity.RemoveClaim(_identity.FindFirst(ClaimTypes.Name)); _identity.AddClaim(new Claim(ClaimTypes.Name, _authUser.FirstName + " " + _authUser.LastName)); //_identity.RemoveClaim(_identity.FindFirst("AccountNo")); //_identity.AddClaim(new Claim("AccountNo", "12345")); _authManager.AuthenticationResponseGrant = new AuthenticationResponseGrant( new ClaimsPrincipal(_identity), new AuthenticationProperties { ExpiresUtc = DateTime.UtcNow.AddMinutes(30), AllowRefresh = true, IsPersistent = false } ); return(RedirectToAction("Dashboard", "Home", new { Area = "Employee" })); } catch (Exception ex) { TempData["Msg"] = AlertMessageProvider.FailureMessage(ex.ToString()); return(View()); } }