Пример #1
0
        public async Task <IActionResult> Post([FromBody] EmployeeDto employeeDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var employee           = new Employee(employeeDto);
            var calculatedBenefits = _benfitsCalcService.Calculate(employee);

            employee.AnnualCostOfBenefits       = calculatedBenefits.AnnualCostOfBenefits;
            employee.CostOfBenefitsPerPayPeriod = calculatedBenefits.CostOfBenefitsPerPayPeriod;
            employee.Discount = calculatedBenefits.DiscountPercentage;
            await _employeeRepo.AddNewEmployee(employee);

            return(Ok(employee));
        }