// // GET: /Home/ public ActionResult Index() { var model = new HomeIndexViewModel { ElementaryMath = new ElementaryMath() }; return View(model); }
public ActionResult Index(ElementaryMath elementaryMath) { if (ModelState.IsValid) { try { elementaryMath.Compute(); } catch (Exception e) { ModelState.AddModelError(String.Empty, e.Message); } } var model = new HomeIndexViewModel { ElementaryMath = elementaryMath }; return View(model); }