public AddOrder(Customer customer) { InitializeComponent(); ACustomer = customer; Coffee aCoffee = new Coffee(); CoffeeDarkRoast aDarkRoastCoffee = new CoffeeDarkRoast(); SandwichWithBacon aBaconSandwich = new SandwichWithBacon(); SandwichWithEggSalad aEggSandwich = new SandwichWithEggSalad(); SandwichWithRoastedBeef aRoastBeefSandwich = new SandwichWithRoastedBeef(); Tea aTea = new Tea(); Milk aMilk = new Milk(); Suggar aSuggar = new Suggar(); Sweetener aSweetner = new Sweetener(); Cheese aCheese = new Cheese(); Mayo aMayo = new Mayo(); Lettuce aLettuce = new Lettuce(); Tomato aTomato = new Tomato(); lbxOrders.Items.Add(aCoffee); lbxOrders.Items.Add(aDarkRoastCoffee); lbxOrders.Items.Add(aBaconSandwich); lbxOrders.Items.Add(aEggSandwich); lbxOrders.Items.Add(aRoastBeefSandwich); lbxOrders.Items.Add(aTea); lbxAdditions.Items.Add(aSweetner); lbxAdditions.Items.Add(aMilk); lbxAdditions.Items.Add(aSuggar); lbxAdditions.Items.Add(aCheese); lbxAdditions.Items.Add(aMayo); lbxAdditions.Items.Add(aLettuce); lbxAdditions.Items.Add(aTomato); }
public ActionResult EditSweeteners(ICollection <MenuItem> sweeteners) { Models.Customer customer = GetLoggedInCustomer(); Models.OrderItem orderItem = GetOrderItem(customer.CurrentOrderItemId); List <Sweetener> sweetenerList = new List <Sweetener>(); for (int i = 0; i < sweeteners.Count(); i++) { MenuItem setSweetener = sweeteners.ElementAt(i); if (setSweetener.Quantity == null) { setSweetener.Quantity = 0; } Sweetener newSweetener = new Sweetener(); newSweetener.SweetenerType = setSweetener.Name; newSweetener.Scoops = setSweetener.Quantity; newSweetener.OrderItemId = orderItem.OrderItemId; newSweetener.Price = (setSweetener.Price * setSweetener.Quantity); sweetenerList.Add(null); sweetenerList[i] = new Sweetener(); sweetenerList[i].SweetenerType = newSweetener.SweetenerType; sweetenerList[i].Scoops = newSweetener.Scoops; sweetenerList[i].OrderItemId = newSweetener.OrderItemId; sweetenerList[i].Price = newSweetener.Price; db.SaveChanges(); } orderItem.Sweeteners = sweetenerList; db.SaveChanges(); return(RedirectToAction("ReviewOrder", new { id = orderItem.OrderItemId })); }
public void AddAnOrder(IMenuItem aItem) { AMenuItemAddition = lbxAdditions.SelectedItem as MenuItemAddition; if (AMenuItemAddition is Suggar) { CurrentOrder = new Suggar(aItem); lbxOrdered.Items.Clear(); lbxOrdered.Items.Add(CurrentOrder); } else if (AMenuItemAddition is Milk) { CurrentOrder = new Milk(aItem); lbxOrdered.Items.Clear(); lbxOrdered.Items.Add(CurrentOrder); } else if (AMenuItemAddition is Sweetener) { CurrentOrder = new Sweetener(aItem); lbxOrdered.Items.Clear(); lbxOrdered.Items.Add(CurrentOrder); } else if (AMenuItemAddition is Lettuce) { CurrentOrder = new Lettuce(aItem); lbxOrdered.Items.Clear(); lbxOrdered.Items.Add(CurrentOrder); } else if (AMenuItemAddition is Tomato) { CurrentOrder = new Tomato(aItem); lbxOrdered.Items.Clear(); lbxOrdered.Items.Add(CurrentOrder); } else if (AMenuItemAddition is Cheese) { CurrentOrder = new Cheese(aItem); lbxOrdered.Items.Clear(); lbxOrdered.Items.Add(CurrentOrder); } else if (AMenuItemAddition is Mayo) { CurrentOrder = new Mayo(aItem); lbxOrdered.Items.Clear(); lbxOrdered.Items.Add(CurrentOrder); } }
private void BtnAdd_Click(object sender, EventArgs e) { if (menuGridView.CurrentRow == null) { return; } IMenuItem item = new Coffee(); if (menuGridView.CurrentRow.Index == 1) { item = new CoffeeDarkRoast(); } else if (menuGridView.CurrentRow.Index == 2) { item = new Tea(); } else if (menuGridView.CurrentRow.Index == 3) { item = new SandwichWithBacon(); } else if (menuGridView.CurrentRow.Index == 4) { item = new SandwichWithEggSalad(); } else if (menuGridView.CurrentRow.Index == 5) { item = new SandwichWithRoastedBeef(); } for (int i = 0; i < NUD_Cheese.Value; i++) { item = new Cheese(item); } for (int i = 0; i < NUD_Lettuce.Value; i++) { item = new Lettuce(item); } for (int i = 0; i < NUD_Mayo.Value; i++) { item = new Mayo(item); } for (int i = 0; i < NUD_Milk.Value; i++) { item = new Milk(item); } for (int i = 0; i < NUD_Sugar.Value; i++) { item = new Suggar(item); } for (int i = 0; i < NUD_Sweetener.Value; i++) { item = new Sweetener(item); } for (int i = 0; i < NUD_Tomato.Value; i++) { item = new Tomato(item); } orderListGridView.Rows.Add(); orderListGridView.Rows[numberOfRows].Cells[0].Value = item.Description; orderListGridView.Rows[numberOfRows++].Cells[1].Value = item.Cost; items.Add(item); }