public ActionResult Delete(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } EditViewModel evm = new EditViewModel(id); if (evm.Delete() > 0) { return RedirectToAction("Index", "Student"); } else { return View(evm); } //Or do this (does not work). //EditViewModel evm = new EditViewModel(); //evm.Delete(id); //return RedirectToAction("Index", "Student"); }
public ActionResult Edit(EditViewModel vm) { if (ModelState.IsValid) { EditViewModel evm = new EditViewModel(); if (evm.Update(vm.Student) > 0) { return RedirectToAction("Details", "Student", new { id = vm.Student.ID }); } else { return View(vm); } } return View(vm); }