コード例 #1
0
 public ActionResult Edit(int id)
 {
     using (FoodManagementEntities3 fd = new FoodManagementEntities3())
     {
         return(View(fd.FoodItems.Where(x => x.Id == id).FirstOrDefault()));
     }
 }
コード例 #2
0
 // GET: Menu
 public ActionResult GetFoodItem1()
 {
     using (FoodManagementEntities3 fd = new FoodManagementEntities3())
     {
         return(View(fd.FoodItems.ToList()));
     }
 }
コード例 #3
0
 public ActionResult Edit(int id, FoodItem item)
 {
     using (FoodManagementEntities3 fd = new FoodManagementEntities3())
     {
         fd.Entry(item).State = EntityState.Modified;
         fd.SaveChanges();
     }
     return(RedirectToAction("GetFoodItem1"));
 }
コード例 #4
0
 public ActionResult AddFoodItem1(FoodItem item)
 {
     using (FoodManagementEntities3 fd = new FoodManagementEntities3())
     {
         fd.FoodItems.Add(item);
         fd.SaveChanges();
     }
     return(RedirectToAction("GetFoodItem1"));
 }
コード例 #5
0
 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"));
 }