public ActionResult Index() { TrainingProductViewModel vm = new TrainingProductViewModel(); vm.HandleRequest(); return View(vm); }
public ActionResult Index(TrainingProductViewModel vm) { vm.IsValid = ModelState.IsValid; vm.HandleRequest(); if(vm.IsValid) { ModelState.Clear(); } else { foreach(KeyValuePair<string,string> item in vm.ValidationErrors) { ModelState.AddModelError(item.Key, item.Value); } } return View(vm); }