Пример #1
0
        public async Task <IActionResult> GetTaxBasedOnIncomeAsync([FromBody] PostParamsDTO requestData)
        {
            //var postalCode = requestData["input"].ToObject<string>();
            var postalCode   = requestData.postalCode;
            var annualIncome = requestData.annualIncome;

            var result = await _taxCalculatorRepository.CalculateTaxAsync(postalCode, annualIncome);

            return(Ok(result));
        }
Пример #2
0
        public IActionResult CalculateTax(string postalCode, decimal annualIncome)
        //public IActionResult CalculateTax([FromBody] PostParamsDTO requestData)
        {
            try
            {
                //string url = "http://*****:*****@"application/json");
                restRequest.Resource = "CalcTaxBasedOnIncome";
                restRequest.AddJsonBody(input);

                var response = restClient.Execute <string>(restRequest);

                ResponseDTO responseVal = JsonConvert.DeserializeObject <ResponseDTO>(response.Content);

                ViewBag.PostalCode         = string.Format("Postal Code : {0}", string.IsNullOrEmpty(postalCode) == true ? "None" : postalCode);
                ViewBag.AnnualIncome       = string.Format("Annual Income : {0}", annualIncome);
                ViewBag.Status             = string.Format("Status : {0}", responseVal.status);
                ViewBag.Message            = string.Format("Message : {0}", responseVal.message);
                ViewBag.TaxValue           = string.Format("Tax Value : {0:0.##}", responseVal.taxValue);
                ViewBag.CalcType           = string.Format("Type Of Calculation : {0}", responseVal.typeOfCalculation ?? "None");
                ViewBag.TotalAfterTax      = string.Format("Total After Tax : {0:0.##}", responseVal.totalAfterTax);
                ViewBag.TotalTaxPercentage = string.Format("Total Tax Percentage : {0:0.##} %", responseVal.totalTaxPercentage);
                return(View("Index"));
            }
            catch (Exception ex)
            {
                ViewBag.Status  = string.Format("Status : {0}", "Incomplete");
                ViewBag.Message = string.Format("Message : {0}", ex.Message);
                return(View("Index"));
                //return Json(new { Success = false, Message = ex.Message });
            }
        }