public bool InOptOutPeriod(EmployeeContractChanges contract, Employee employee) { DateTime today = DateTime.Today; DateTime OptOutPeriod = (employee.LastUpdate).AddDays(90.00); return((OptOutPeriod <= today) ? false : true); }
public void ResetContractChange(int userID, EmployeeContractChanges contract) {//Will reset the user account information based on Last Change Log ID and earliest created entry with this //change log id. int lastChangeLogID = GetLCF(userID).ChangeLogID; AuthenticateContext db = EmpContractChangesDbContext; var result = db.EmployeeContractChanges .Where(x => x.ChangeLogID == lastChangeLogID) .OrderBy(x => x.ID).FirstOrDefault(); Employee employeeToUpdate = EmpContractChangesDbContext.Employees.FirstOrDefault(x => x.ID == userID); employeeToUpdate.LastName = result.NewLastName; employeeToUpdate.Email = result.NewEmail; employeeToUpdate.Address = result.NewAddress; employeeToUpdate.City = result.NewCity; employeeToUpdate.State = result.NewState; employeeToUpdate.Zipcode = result.NewZipcode; employeeToUpdate.Country = result.NewCountry; employeeToUpdate.HomePhone = result.NewHomePhone; db.SaveChanges(); var lastCF = GetLCF(userID); lastCF.StatusID = db.FormStatuses .Where(x => x.StatusName == "Opt-out") .ToList().First().ID; db.SaveChanges(); }
public bool CanEditCF(EmployeeContractChanges contract, int UserID) { bool canEditCF = false; return(canEditCF); }
public EmployeeSurveyViewModel EmployeeSurveyViewModel(EmployeeContractChanges contract) { return(new ViewModels.EmployeeSurveyViewModel() { NewAddress = contract.NewAddress, NewCity = contract.NewCity, NewCountry = contract.NewCountry, NewEmail = contract.NewEmail, NewHomePhone = contract.NewHomePhone, NewLastName = contract.NewLastName, NewState = contract.NewState, NewZipcode = contract.NewZipcode, StatusID = contract.StatusID }); }
public HRDashboardViewModel HRDashboardViewModel(EmployeeContractChanges contract, string form = "editing") { return(new HRDashboardViewModel() { NewAddress = contract.NewAddress, NewCity = contract.NewCity, NewCountry = contract.NewCountry, NewEmail = contract.NewEmail, NewHomePhone = contract.NewHomePhone, NewLastName = contract.NewLastName, NewState = contract.NewState, NewZipcode = contract.NewZipcode, StatusID = contract.StatusID, FormType = form }); }
public HRDashboardViewModel HRDashboardViewModelLastCF(Employee employee, string form, int statusID) { bool ContractIsInProgress = CFInProgress(employee);//Need to pass in contract id if editing. EmployeeContractChanges lastCF = GetLCF(employee.ID); return(new HRDashboardViewModel() { NewAddress = ContractIsInProgress ? lastCF.NewAddress: employee.Address, NewCity = ContractIsInProgress ? lastCF.NewCity : employee.City, NewCountry = ContractIsInProgress ? lastCF.NewCountry : employee.Country, NewEmail = ContractIsInProgress ? lastCF.NewEmail : employee.Email, NewHomePhone = ContractIsInProgress ? lastCF.NewHomePhone : employee.HomePhone, NewLastName = ContractIsInProgress ? lastCF.NewLastName: employee.LastName, NewState = ContractIsInProgress ? lastCF.NewState : employee.State, NewZipcode = ContractIsInProgress ? lastCF.NewZipcode : employee.Zipcode, StatusID = ContractIsInProgress ? lastCF.StatusID: statusID, FormType = form }); }
public void CheckApproved(EmployeeContractChanges contract, int UserID) {//Updates a contract to approved and updates user with new contact info. AuthenticateContext db = EmpContractChangesDbContext; var status = db.FormStatuses.Where(x => x.ID == contract.StatusID).FirstOrDefault(); if (status != null && status.StatusName.Contains("Approved")) { UpdateEmployee(new Employee { ID = UserID, LastName = contract.NewLastName, Email = contract.NewEmail, Address = contract.NewAddress, City = contract.NewCity, State = contract.NewState, Zipcode = contract.NewZipcode, Country = contract.NewCountry, HomePhone = contract.NewHomePhone }); } }
public bool CFInProgress(Employee employee) { bool CFInProgress = false; int UserID = employee.ID; EmployeeContractChanges lastCF = GetLCF(UserID); if (lastCF != null) { CFInProgress = StatusIs(lastCF.StatusID) == "Opt-Out" ? false : true; if (StatusIs(lastCF.StatusID) != "Opt-Out") { CFInProgress = InOptOutPeriod(lastCF, employee) ? true : false; } } return(CFInProgress); }
public void InsertEmployeeContractChanges(EmployeeContractChanges contract, int employeeID, bool editing = false, bool survey = false) { Employee employeeToUpdate = EmpContractChangesDbContext.Employees .FirstOrDefault(x => x.ID == employeeID); //Only supposed to do this when user is filling out survey. if (survey) { employeeToUpdate.LastUpdate = DateTime.Now; } EmployeeContractChanges eCC = new EmployeeContractChanges(); EmployeeContractChanges lastCF = GetLCF(employeeToUpdate.ID); //Check if contract with given id exists, if it does do block 2, if it does not do block 1 and 2. bool contractInProgress = false; bool contractExists = false; int newChangeLogID = 1; if (lastCF != null) { contractExists = EmpContractChangesDbContext .EmployeeContractChanges.Find(lastCF.ID) != null ? true : false; contractInProgress = CFInProgress(employeeToUpdate); newChangeLogID = lastCF.ChangeLogID + 1; } LegalForm legalform = new LegalForm() { FilePath = "N/A", Reason = "N/A" }; if (!contractExists || !contractInProgress) {//1 - Brand new entry into EmployeeContractChange table. legalform = CreateNewLegalForm(legalform); eCC.LegalForm = legalform; eCC.LegalFormsID = legalform.ID; eCC.StatusID = 1; eCC.EmployeeID = employeeToUpdate.ID; eCC.ChangeLogID = !contractInProgress ? newChangeLogID : 1; eCC.NewAddress = employeeToUpdate.Address; eCC.NewCity = employeeToUpdate.City; eCC.NewCountry = employeeToUpdate.Country; eCC.NewEmail = employeeToUpdate.Email; eCC.NewHomePhone = employeeToUpdate.HomePhone; eCC.NewLastName = employeeToUpdate.LastName; eCC.NewState = employeeToUpdate.State; eCC.NewZipcode = employeeToUpdate.Zipcode; eCC.DateCreated = DateTime.Now; EmpContractChangesDbContext.EmployeeContractChanges.Add(eCC); EmpContractChangesDbContext.SaveChanges(); } EmployeeContractChanges eCC_NEW = new EmployeeContractChanges(); ///2 eCC_NEW.LegalFormsID = lastCF != null ? lastCF.LegalFormsID : legalform.ID; eCC_NEW.StatusID = contract.StatusID == 0 ? 1 : contract.StatusID; //WILL BE PROVIDING STATUS eCC_NEW.EmployeeID = employeeToUpdate.ID; eCC_NEW.ChangeLogID = (!contractExists || !contractInProgress) ? eCC.ChangeLogID : lastCF.ChangeLogID; eCC_NEW.NewAddress = contract.NewAddress; eCC_NEW.NewCity = contract.NewCity; eCC_NEW.NewCountry = contract.NewCountry; eCC_NEW.NewEmail = contract.NewEmail; eCC_NEW.NewHomePhone = contract.NewHomePhone; eCC_NEW.NewLastName = contract.NewLastName; eCC_NEW.NewState = contract.NewState; eCC_NEW.NewZipcode = contract.NewZipcode; eCC_NEW.DateCreated = DateTime.Now; EmpContractChangesDbContext.EmployeeContractChanges.Add(eCC_NEW); EmpContractChangesDbContext.SaveChanges(); }