private void CheckModel(QuoteScheduleViewModel model) { if (model.DepositAmount > model.TotalPrice) { ModelState.AddModelError(nameof(model.DepositAmount), "Deposit cannot be greater than the total."); } if (model.DepositAmount < model.TotalPrice * 0.15m) { ModelState.AddModelError(nameof(model.DepositAmount), "Deposit amount must be greater than 15% of the total."); } }
public ActionResult Index(QuoteScheduleViewModel model) { CheckModel(model); if (ModelState.IsValid) { model.Schedule = _quoteService.GenerateQuoteSchedule( new QuoteServiceParameters( model.SelectedLoanTerm, (double)(model.TotalPrice - model.DepositAmount), model.DeliveryDate)); } return(View(model)); }