public ActionResult Calculate(TestViewModel Test) { TestShowViewModel TestShowViewModel = new TestShowViewModel(); try { if (ModelState.IsValid) { if (Test.input >= 0) { TestShowViewModel.AllUpToInc = GetAllUpToInc(Test.input); TestShowViewModel.AllOddUpToInc = GetAllOddUpToInc(Test.input); TestShowViewModel.AllEvenUpToInc = GetAllEvenUpToInc(Test.input); TestShowViewModel.AllExcept = GetAllExcept(Test.input); TestShowViewModel.AllFibonacci = GetAllFibonacci(Test.input); return View("Results", TestShowViewModel); } else { ModelState.AddModelError("", "Please enter a Positive number"); } } else { ModelState.AddModelError("", "An error occured. Please try again"); } } catch(Exception) { ModelState.AddModelError("", "An error occured. Please try again"); } return View("Index"); }
public ActionResult Index() { TestViewModel TestViewModel = new TestViewModel(); return View(TestViewModel); }