//When a new OrderItem is added, subtotal, tax, and total are //automatically updated. public void AddItemToOrder(OrderItem newOrderItem) { bool addItemToOrder = true; if (newOrderItem != null) { if (newOrderItem is Drink) { Drink drinkToAdd = (Drink)newOrderItem; if (UpdateDrinkIfAlreadyOnOrder(drinkToAdd)) { addItemToOrder = false; } } else if (newOrderItem is Dessert) { Dessert dessertToAdd = (Dessert)newOrderItem; if (UpdateDessertIfAlreadyOnOrder(dessertToAdd)) { addItemToOrder = false; } } else if (newOrderItem is Pizza) { Pizza pizzaToAdd = (Pizza)newOrderItem; if (UpdatePizzaIfAlreadyOnOrder(pizzaToAdd)) { addItemToOrder = false; } } else if (newOrderItem is Calzone) { Calzone calzoneToAdd = (Calzone)newOrderItem; if (UpdateCalzoneIfAlreadyOnOrder(calzoneToAdd)) { addItemToOrder = false; } } else if (newOrderItem is Salad) { Salad saladToAdd = (Salad)newOrderItem; if (UpdateSaladIfAlreadyOnOrder(saladToAdd)) { addItemToOrder = false; } } if (addItemToOrder) { newOrderItem.OrderItemNumber = OrderItems.Count + 1; OrderItems.Add(newOrderItem); } UpdateOrderTotals(); MenuHeaderModel.Instance.OrderTotal = Total; } }
public bool UpdateCalzoneIfAlreadyOnOrder(Calzone calzoneToAdd) { foreach (var orderItem in OrderItems) { if (orderItem is Calzone) { Calzone calzoneAlreadyOnOrder = (Calzone)orderItem; if (EditingExistingOrder) { orderItem.ItemCount = calzoneToAdd.ItemCount; return(true); } else if (calzoneToAdd.CalzoneType == calzoneAlreadyOnOrder.CalzoneType && calzoneToAdd.Toppings.AreToppingsTheSame(calzoneAlreadyOnOrder.Toppings.CurrentToppings)) { orderItem.ItemCount++; return(true); } } } return(false); }
public CalzoneToppings(CalzoneType calzoneType, Calzone thisCalzone) { ThisCalzone = thisCalzone; CalzoneType = calzoneType; }