예제 #1
0
 public ActionResult Delete(int? id)
 {
     MenuDB db = new MenuDB();
     Menu menu = db.Menus.Find(id);
     db.Menus.Remove(menu);
     db.SaveChanges();
     ViewBag.Info = string.Format(
     "Menu item deleted: {0}", menu.Id);
     return View("Index", db.Menus.ToList());
 }
예제 #2
0
 public ActionResult SubmitData(Menu m)
 {
     if (ModelState.IsValid)
     {
         m.Date = DateTime.Now;
         MenuDB context = new MenuDB();
         context.Menus.Add(m);
         context.SaveChanges();
         ViewBag.Info = string.Format(
             "Menu created: {0}, Price: {1}, Category {2}", m.Text, m.Price, m.Category);
     }
     else
     {
         ViewBag.Info = "not valid";
     }
     return View("Index",db.Menus.ToList());
 }