public ActionResult CreateStudent(Student student) { if (ModelState.IsValid) { _db.Students.Add(student); _db.SaveChanges(); return RedirectToAction("Index"); } return View(student); }
public ActionResult Edit(Student student) { if (ModelState.IsValid) { Student oldStudent = _db.Students.Find(student.StudentID); oldStudent.LastName = student.LastName; oldStudent.FirstMidName = student.FirstMidName; oldStudent.EnrollmentDate = student.EnrollmentDate; int i = _db.SaveChanges(); return RedirectToAction("Index"); } return View(student); }
public ActionResult Delete(Student student) { _db.Students.Remove(_db.Students.Find(student.StudentID)); _db.SaveChanges(); return RedirectToAction("Index"); }