public IHttpActionResult Get(string countryCode, double hoursWorked, double hourlyRate)
        {
            if (string.IsNullOrEmpty(countryCode) || string.IsNullOrEmpty(countryCode))
            {
                BadRequest("Country code cannot be empty");
            }

            if (hoursWorked < 0)
            {
                BadRequest("Please provide valid Work Hours");
            }

            if (hourlyRate < 0)
            {
                BadRequest("Please provide valid Hourly rate");
            }

            try
            {
                var model = _payrollService.CalculatePay(countryCode, hoursWorked, hourlyRate);

                return(Ok(new { success = true, salary = model }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
        public async Task <IActionResult> Save([FromServices] IPayrollService payrollService, [FromBody] SaveEmployeeRequest request)
        {
            var employee = _mapper.Map <Employee>(request.Employee);

            payrollService.CalculatePay(employee);
            await _employeeRepository.Add(employee);

            return(NoContent());
        }
        public ActionResult <PreviewEmployeeCostsResponse> PreviewCosts([FromServices] IPayrollService payrollService, [FromBody] PreviewEmployeeCostRequest request)
        {
            var response = new PreviewEmployeeCostsResponse();
            var employee = _mapper.Map <Employee>(request.Employee);

            payrollService.CalculatePay(employee);
            response.AnnualPay   = _mapper.Map <EmployeePayDto>(employee.AnnualPay);
            response.PaycheckPay = _mapper.Map <EmployeePayDto>(employee.PaycheckPay);
            return(response);
        }
        public async Task <ActionResult <EmployeeResponse> > UpdateEmployee(int id, [FromServices] IPayrollService payrollService, [FromBody] SaveEmployeeRequest request)
        {
            var employee = await _employeeRepository.Get(id);

            _mapper.Map(request.Employee, employee);
            payrollService.CalculatePay(employee);
            await _employeeRepository.SaveChanges();

            return(NoContent());
        }