public ActionResult Edit(int? id) { if(id != null) { StudentRepository repository = new StudentRepository(); var model = repository.GetStudentById(id.Value); return View(model); } return View(); }
public ActionResult Edit(int? id) { if (id.HasValue) { int theID = id.Value; StudentRepository repository = new StudentRepository(); Student model = repository.GetStudentById(theID); if (model == null) return View("NotFound"); return View(model); } else
public ActionResult Edit(int id, FormCollection formData) { StudentRepository repository = new StudentRepository(); Student s = repository.GetStudentById(id); if (s != null) { UpdateModel(s); repository.UpdateStudent(s); return RedirectToAction("Index"); } else { return View("NotFound"); } }