public ActionResult SaveOrder(OrderIndexVM orderIndexVM) { //saves to the table var order = new Order { CustomerID = orderIndexVM.CustomerID, LocationID = orderIndexVM.LocationID, Total = GetTotal(orderIndexVM.DrinkOrders) }; order = _orderBL.AddOrder(order); foreach (var item in orderIndexVM.DrinkOrders) { if (item.Quantity > 0) { var drinkOrder = new DrinkOrder { DrinkId = item.DrinkId, OrderId = order.OrderID, Quantity = item.Quantity }; _orderBL.AddDrinkOrder(drinkOrder); } var inventory = _inventoryBL.GetInventoryByLocationIDAndDrinkID(order.LocationID, item.DrinkId); if (inventory != null) { inventory.Quantity -= item.Quantity; _inventoryBL.UpdateInventory(inventory); } } return(RedirectToAction("Index", "Home")); }