public ActionResult Edit(int id) { using (FoodManagementEntities3 fd = new FoodManagementEntities3()) { return(View(fd.FoodItems.Where(x => x.Id == id).FirstOrDefault())); } }
// GET: Menu public ActionResult GetFoodItem1() { using (FoodManagementEntities3 fd = new FoodManagementEntities3()) { return(View(fd.FoodItems.ToList())); } }
public ActionResult Edit(int id, FoodItem item) { using (FoodManagementEntities3 fd = new FoodManagementEntities3()) { fd.Entry(item).State = EntityState.Modified; fd.SaveChanges(); } return(RedirectToAction("GetFoodItem1")); }
public ActionResult AddFoodItem1(FoodItem item) { using (FoodManagementEntities3 fd = new FoodManagementEntities3()) { fd.FoodItems.Add(item); fd.SaveChanges(); } return(RedirectToAction("GetFoodItem1")); }
public ActionResult Delete(int id) { using (FoodManagementEntities3 fd = new FoodManagementEntities3()) { FoodItem i = fd.FoodItems.Where(x => x.Id == id).FirstOrDefault(); fd.FoodItems.Remove(i); fd.SaveChanges(); } return(RedirectToAction("GetFoodItem1")); }