public ActionResult Index(SumViewModel model) { if (!this.ModelState.IsValid) { return this.RedirectToAction("Index", "Home", new { isValid = true }); } model.TotalSum = model.FirstNumber + model.SecondNumber; return this.RedirectToAction("Index", "Home", new { totalSum = model.TotalSum, isValid = false }); }
public ActionResult Index(decimal? totalSum, bool isValid = false) { var sum = new SumViewModel { FirstNumber = 0m, SecondNumber = 0m, TotalSum = totalSum ?? 0 }; this.ViewBag.IsValid = isValid; return this.View(sum); }