{// 1. *************RETRIEVE ALL Staff DETAILS ****************** // GET: Staff public ActionResult StaffList() { StaffMasterDbHandle dbhandle = new StaffMasterDbHandle(); ModelState.Clear(); return(View(dbhandle.GetStaff())); }
public ActionResult Edit(int id, Staff smodel) { try { StaffMasterDbHandle sdb = new StaffMasterDbHandle(); sdb.UpdateDetails(smodel); return(RedirectToAction("StaffList")); } catch (Exception ex) { Console.WriteLine(ex); return(View()); } }
// 4. ************* DELETE Staff DETAILS ****************** // GET: Staff/Delete/5 public ActionResult Delete(int id) { try { StaffMasterDbHandle sdb = new StaffMasterDbHandle(); if (sdb.DeleteStaff(id)) { ViewBag.AlertMsg = "S Deleted Successfully"; } return(RedirectToAction("StaffList")); } catch { return(View()); } }
public ActionResult Create(Staff smodel) { try { if (ModelState.IsValid) { StaffMasterDbHandle sdb = new StaffMasterDbHandle(); if (sdb.AddStaff(smodel)) { ViewBag.Message = "Staff Details Added Successfully"; ModelState.Clear(); } } return(View()); } catch (Exception ex) { ex.StackTrace.ToString(); return(View()); } }
// 3. ************* EDIT Staff DETAILS ****************** // GET: Staff/Edit/5 public ActionResult Edit(int id) { StaffMasterDbHandle sdb = new StaffMasterDbHandle(); return(View(sdb.GetStaff().Find(smodel => smodel.StaffId == id))); }