public EmployeeGrossSalaryResponse Map(EmployeeDetailsRequest request, TaxRate matchingTaxRate) => new EmployeeGrossSalaryResponse { EmployeeFullName = $"{request.FirstName} {request.LastName}", GrossIncome = CalculateGrossIncome(request.AnnualSalary), IncomeTax = CalculateIncomeTax(request.AnnualSalary, matchingTaxRate), Super = (CalculateGrossIncome(request.AnnualSalary) / 100) * request.SuperRate };
public HttpResponseMessage Process(EmployeeDetailsRequest request) { //TODO: return Bad request if (!_requestValidator.IsValid()) { return(null); } var matchingTaxRate = GetTaxRate(request.AnnualSalary); return(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(_mapper.Map(request, matchingTaxRate))) }); }
public static HttpResponseMessage Run( [HttpTrigger(AuthorizationLevel.Function, "get", Route = ApiUri)] EmployeeDetailsRequest request, TraceWriter log) { log.Info($"Received request for gross payment processing for employee {request.FirstName} {request.LastName}"); try { var paymentProcessorService = new PaymentProcessorService(new RequestValidator(), new Mapper()); return(paymentProcessorService.Process(request)); } catch (Exception e) { Console.WriteLine(e); throw; } }