示例#1
0
        public ActionResult Update(int tableOrderId, int dishId, int quantity)
        {
            TableOrder foundOrder = TableOrder.Find(tableOrderId);

            foundOrder.UpdateDish(dishId, quantity);
            return(RedirectToAction("Show"));
        }
示例#2
0
        public void UpdateDish_UpdatesDishQuantityInJointTable_Dish()
        {
            string   name        = "Eggs and Bacon";
            string   tableNumber = "4";
            DateTime orderDate   = new DateTime(2019, 3, 12);
            Dish     newDish     = new Dish(name);

            newDish.Save();
            int        dishId        = newDish.GetId();
            TableOrder newTableOrder = new TableOrder(tableNumber, orderDate);

            newTableOrder.Save();
            newTableOrder.AddDish(dishId, 2);
            newTableOrder.UpdateDish(dishId, 3);

            List <DishQuantity> testList = new List <DishQuantity> {
                new DishQuantity(newDish, 3)
            };
            List <DishQuantity> result = newTableOrder.GetAllDishes();

            CollectionAssert.AreEqual(testList, result);
        }