Exemplo n.º 1
0
        public IActionResult Index()
        {
            AppVariable taxRate = _appVariableRepository.GetBy("TaxRate");

            try
            {
                ViewBag.CurrentTaxRate = Convert.ToDouble(taxRate.Value);
            }
            catch (Exception e)
            {
                // do something
            }
            return(View());
        }
        public IActionResult Index(DonationViewModel model)
        {
            var values = ModelState.Values;

            if (ModelState.IsValid)
            {
                try
                {
                    var         taxRate = Convert.ToDouble(_appVariableRepository.GetBy("TaxRate"));
                    Calculation calc    = new Calculation(_user, model.Amount, taxRate, model.EventType);
                    // store in repository
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", e.Message);
                }
                return(RedirectToAction(nameof(Result), new { amount = model.Amount, eventType = model.EventType }));
                // change this to comply with new Calculation class
            }
            return(View(model));
        }