public ActionResult Calculate(int creditTypeId, CalculationModel model) { var creditType = creditTypeService.GetCreditTypeById(creditTypeId); if (creditType == null) { return new HttpNotFoundResult(); } if (ModelState.IsValidField("Amount")) { try { model.Result = creditService.CalculateMonthPayment(model.Amount, creditType.ReturnTerm, creditType.Percent); } catch (Exception) { model.Result = -1; } } else { ModelState.Clear(); ModelState.AddModelError("", "Проверьте коректность данных"); } model.CreditType = creditType; return View(model); }
public ActionResult Calculate(int creditTypeId) { var creditType = creditTypeService.GetCreditTypeById(creditTypeId); if (creditType == null) { return new HttpNotFoundResult(); } var calculateModel = new CalculationModel { CreditType = creditType }; return View(calculateModel); }