예제 #1
0
 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
 };
예제 #2
0
        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)))
            });
        }
예제 #3
0
        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;
            }
        }