コード例 #1
0
 public ActionResult CreateStudent(Student student)
 {
     if (ModelState.IsValid) {
         _db.Students.Add(student);
         _db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(student);
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 public ActionResult Delete(Student student)
 {
     _db.Students.Remove(_db.Students.Find(student.StudentID));
     _db.SaveChanges();
     return RedirectToAction("Index");
 }