public ActionResult StaffCreate(Staff item) { if (ModelState.IsValid) { Database.Staffs.Add(item); Database.SaveChanges(); return RedirectToAction("Staff"); } else return View("StaffEdit", item); }
public ActionResult StaffEdit(int id, Staff item) { if (ModelState.IsValid) { var dbItem = Database.Staffs.Find(id); TryUpdateModel(dbItem); Database.SaveChanges(); return RedirectToAction("StaffEdit"); } else return View(item); }
/*This will create a new instance of Material and go to edit mode*/ public ActionResult StaffCreate(string username) { var model = new Staff(); model.userName = username; return View("StaffEdit", model); }