예제 #1
0
        public Order AddMenuToOrder(Order order, Menu menu)
        {
            var ctxOrder = context.Orders.Find(order.Id);
            ctxOrder.Menus.Add(menu);
            context.SaveChanges();

            return ctxOrder;
        }
예제 #2
0
 public ActionResult Create(Menu menu)
 {
     if (ModelState.IsValid) {
         menuRepository.InsertOrUpdate(menu);
         menuRepository.Save();
         return RedirectToAction("Index");
     } else {
         ViewBag.PossibleProductTypes = producttypeRepository.All;
         return View();
     }
 }
예제 #3
0
 public void InsertOrUpdate(Menu menu)
 {
     if (menu.Id == default(System.Guid)) {
         // New entity
         menu.Id = Guid.NewGuid();
         context.Menus.Add(menu);
     } else {
         // Existing entity
         context.Entry(menu).State = EntityState.Modified;
     }
 }