public ActionResult Create(StaffMVC.Models.Staff staff) { try { // TODO: Add insert logic here using (DBModel db = new DBModel()) { db.Staffs.Add(staff); db.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int id, StaffMVC.Models.Staff staff) { try { // TODO: Add delete logic here using (DBModel db = new DBModel()) { staff = db.Staffs.Where(x => x.StaffID == id).FirstOrDefault(); db.Staffs.Remove(staff); db.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, StaffMVC.Models.Staff staff) { try { // TODO: Add update logic here using (DBModel db = new DBModel()) { db.Entry(staff).State = System.Data.EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }