public async Task <ActionResult> UpdateDependent(Dependent dependent) { dependent.Birthdate = ParseDates.ParseDate(dependent.Birthdate); _dependentRepository.Update(dependent); if (await _dependentRepository.SaveAllAsync()) { return(NoContent()); } return(BadRequest("Failed to update dependent")); }
public async Task <ActionResult> UpdateCompany(Company company) { company.CommencementDate = ParseDates.ParseDate(company.CommencementDate); company.YearEndDate = ParseDates.ParseDate(company.YearEndDate); company.GroupTerminationDate = ParseDates.ParseDate(company.GroupTerminationDate); _companyRepository.Update(company); if (await _companyRepository.SaveAllAsync()) { return(NoContent()); } return(BadRequest("Failed to update company")); }
public async Task <ActionResult> UpdateEmployee(Employee employee) { employee.EligibilityDate = ParseDates.ParseDate(employee.EligibilityDate); employee.StartDate = ParseDates.ParseDate(employee.StartDate); employee.TerminationDate = ParseDates.ParseDate(employee.TerminationDate); employee.HireDate = ParseDates.ParseDate(employee.HireDate); _employeeRepository.Update(employee); if (await _employeeRepository.SaveAllAsync()) { return(NoContent()); } return(BadRequest("Failed to update employee")); }
public async Task <ActionResult <Dependent> > CreateDependent(Dependent dependent) { if (await _dependentRepository.DependentExists(dependent)) { return(BadRequest("A Dependent with the name '" + dependent.FirstName + ' ' + dependent.LastName + "' already exists for this employee")); } dependent.Birthdate = ParseDates.ParseDate(dependent.Birthdate); _dependentRepository.Add(dependent); if (await _dependentRepository.SaveAllAsync()) { return(NoContent()); } return(BadRequest("Failed to add dependent")); }
public async Task <ActionResult <Company> > CreateCompany(Company company) { if (await _companyRepository.CompanyExists(company.CompanyName)) { return(BadRequest("A Company with the name '" + company.CompanyName + "' already exists")); } company.CommencementDate = ParseDates.ParseDate(company.CommencementDate); company.YearEndDate = ParseDates.ParseDate(company.YearEndDate); _companyRepository.Add(company); if (await _companyRepository.SaveAllAsync()) { return(NoContent()); } return(BadRequest("Failed to add company")); }
public async Task <ActionResult <Employee> > CreateEmployee(Employee employee) { if (await _employeeRepository.EmployeeExists(employee.SIN)) { return(BadRequest("Employee already exists")); } employee.EligibilityDate = ParseDates.ParseDate(employee.EligibilityDate); employee.StartDate = ParseDates.ParseDate(employee.StartDate); employee.TerminationDate = ParseDates.ParseDate(employee.TerminationDate); employee.HireDate = ParseDates.ParseDate(employee.HireDate); _employeeRepository.Add(employee); if (await _employeeRepository.SaveAllAsync()) { return(NoContent()); } return(BadRequest("Failed to add Employee")); }