public ActionResult Create(staff_program staff_program) { try { using (DBModel dbModel = new DBModel()) { dbModel.staff_program.Add(staff_program); dbModel.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, staff_program staff_program) { try { using (DBModel dbModel = new DBModel()) { dbModel.Entry(staff_program).State = EntityState.Modified; dbModel.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int id, FormCollection collection) { try { using (DBModel dBModel = new DBModel()) { staff_program staff_program = dBModel.staff_program.Where(x => x.id == id).FirstOrDefault(); dBModel.staff_program.Remove(staff_program); dBModel.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }