public void addFezItemToList() { FezSize fez_size = new FezSize("Test Fez Size", 1.3); FezStyle fez_style = new FezStyle("Long Description", "Short", 15.0m, true); myBasket.Add(fez_size, fez_style); Assert.True(myBasket.Count() == 1); }
private void AddToBasket(object o, bool isNewData = true) { Dish clone = (o as Dish).Clone(); BasketList.Add(clone); SelectedBasketItem = clone; CalculateBasketPrice(); }
private void addItemButton_Click(object sender, RoutedEventArgs e) { XmlElement fezStyleSelectedElement = this.comboBoxStyle.SelectedItem as XmlElement; XmlElement fezSizeSelectedElement = this.comboBoxSize.SelectedItem as XmlElement; try{ shopping_basket.Add( new FezSize(fezSizeSelectedElement.Attributes["Label"].Value as String, Convert.ToDouble(fezSizeSelectedElement.Attributes["PriceModifier"].Value as String)), new FezStyle(fezStyleSelectedElement.Attributes["LongDescription"].Value as String, fezStyleSelectedElement.Attributes["ShortDescription"].Value as String, Convert.ToDecimal(fezStyleSelectedElement.Attributes["BasePrice"].Value as String), Convert.ToBoolean(fezStyleSelectedElement.Attributes["SupportsTassels"].Value as String))); } catch (NullReferenceException) { } }
public static void RenderBasket(GroupBox gbSender) { //Finding the final parent (the main form (ShopForm)) ShopGBControl sgbcSender = (ShopGBControl)gbSender.Parent; FlowLayoutPanel flpSender = (FlowLayoutPanel)sgbcSender.Parent; Form baseForm = (Form)flpSender.Parent; //Generating an IEnumerable of required type var flpList = baseForm.Controls.OfType <FlowLayoutPanel>(); //Looping through the flpList, looking for the needed FlowLayoutPanel //Checking whether the item is already in there and adding it if needed //Or displaying an error message foreach (var flp in flpList) { if (flp.Name == "BasketPanel") { for (int i = 0; i < TempBasketList.Count; i++) { Product prod = TempBasketList[i]; if (!BasketList.Contains(prod)) { prod.Quantity--; Product basketProd = new Product(prod); BasketList.Add(basketProd); flp.Controls.Add(new BasketGBControl(basketProd)); TempBasketList.Clear(); } else { TempBasketList.Clear(); MessageBox.Show("Product is in the basket already"); } } } } }
//public void AddToBasket(object sender, RoutedEventArgs e) //{ // AddCurrentFezItemToBasket(); //} private void AddCurrentFezItemToBasket() { _shopping_basket.Add(SelectedFezSize, SelectedFezStyle); }