public IActionResult Index()
        {
            TaxCalcRequestViewModel model = new TaxCalcRequestViewModel();

            model = SetUpPostalCodes(model);

            return(View(model));
        }
        public IActionResult Index(TaxCalcRequestViewModel taxModel)
        {
            TaxCalculationViewModel taxCalcModel = new TaxCalculationViewModel();

            taxCalcModel.PostalCode   = taxModel.SelectedPostalCode;
            taxCalcModel.AnnualIncome = Double.Parse(taxModel.AnnualIncome.ToString());
            taxCalcModel.TaxAmount    = 0;

            var PostResult = PostAsync(taxCalcModel).GetAwaiter().GetResult();

            taxModel = SetUpPostalCodes(taxModel);
            return(View(taxModel));
        }
        public string GetTaxAmount(TaxCalcRequestViewModel tModel)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:44341/api/");

                var postTask = client.PostAsync("TaxCalculation", new StringContent(JsonConvert.SerializeObject(tModel)));

                var result = postTask.Result.Content.ReadAsStringAsync();
                result.Wait();

                string resultContent = result.ToString();

                return(resultContent);
            }
        }
        private TaxCalcRequestViewModel SetUpPostalCodes(TaxCalcRequestViewModel model)
        {
            List <SelectListItem> postCodeList = new List <SelectListItem>();

            postCodeList.Add(new SelectListItem()
            {
                Value = "7441", Text = "7441"
            });
            postCodeList.Add(new SelectListItem()
            {
                Value = "1000", Text = "1000"
            });
            postCodeList.Add(new SelectListItem()
            {
                Value = "A100", Text = "A100"
            });
            postCodeList.Add(new SelectListItem()
            {
                Value = "7000", Text = "7000"
            });

            model.PostalCodes = postCodeList;
            return(model);
        }