public async Task <ActionResult> Index(int donatedAmount, int taxRate, string supplement = "0") { try { if (supplement == null) { supplement = "0"; } if (taxRate != taxRateService.GetTaxRate()) { taxRateService.SaveTaxRate(taxRate); } CalculatedVM calculatedVM = new CalculatedVM() { DonatedAmount = donatedAmount, DeductibleAmount = calculateService.CalculateDeductible(donatedAmount, taxRateService.GetTaxRate(), float.Parse(supplement)), TaxRate = int.Parse(taxRateService.GetTaxRate().ToString()), Supplement = supplement }; if (donatedAmount < 0 || taxRate < 0) { calculatedVM.DonatedAmount = 0; calculatedVM.DeductibleAmount = 0; } if (donatedAmount < 0) { calculatedVM.ErrorMessage = "Enter a positive dontation amount!"; } if (taxRate < 0) { calculatedVM.ErrorMessage = "Enter a positive tax rate!"; calculatedVM.TaxRate = 0; taxRateService.SaveTaxRate(0); } return(View(calculatedVM)); } catch (Exception ex) { throw ex; } }