public ActionResult Edit(int id, TrainerTestEditViewModel viewModel) { if (viewModel.Id == id) { if (ModelState.IsValid) { var test = new Test { Id = viewModel.Id, Name = viewModel.Name, }; testService.EditTest(test); return Redirect("/trainer/test"); } return View(viewModel); } else { throw new Exception("Dont do this"); } }
public ActionResult Edit(int id) { var test = testService.GetTest(id); var viewModel = new TrainerTestEditViewModel { Id = test.Id, Name = test.Name, }; return View(viewModel); }