Exemplo n.º 1
0
        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"));
        }
Exemplo n.º 2
0
        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"));
        }
Exemplo n.º 3
0
        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"));
        }
Exemplo n.º 4
0
        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"));
        }
Exemplo n.º 5
0
        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"));
        }
Exemplo n.º 6
0
        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"));
        }