// 3. ************* EDIT STUDENT DETAILS ****************** // GET: Student/Edit/5 public ActionResult Edit(int id) { var sdb = new StudentDbHandle(); var sm = new StudentModel(); sm = sdb.GetStudentModels(id).SingleOrDefault(); return(View(sm)); }
// GET: Student/Delete/5 public ActionResult Delete(int id) { StudentDbHandle sdb = new StudentDbHandle(); if (ModelState.IsValid) { if (sdb.DeleteStudentRecords(id)) { ViewBag.Message = "Student Details Deleted Successfully"; ModelState.Clear(); } } var dbHandle = new StudentDbHandle(); return(View("Index", dbHandle.GetStudentModels())); }
public ActionResult Create(StudentModel smodel) { try { StudentDbHandle sdb = new StudentDbHandle(); if (ModelState.IsValid) { if (sdb.AddStudent(smodel)) { ViewBag.Message = "Student Details Added Successfully"; ModelState.Clear(); } } return(View()); } catch { return(View()); } }
public ActionResult Edit(int id, StudentModel smodel) { try { StudentDbHandle sdb = new StudentDbHandle(); if (ModelState.IsValid) { if (sdb.UpdateStudent(smodel)) { ViewBag.Message = "Student Details Added Successfully"; ModelState.Clear(); } } return(RedirectToAction("Index")); } catch { return(View()); } }
// 1. *************RETRIEVE ALL STUDENT DETAILS ****************** // GET: Student public ActionResult Index() { var dbHandle = new StudentDbHandle(); return(View(dbHandle.GetStudentModels())); }