private async void removeButton_clicked(Object sender, System.EventArgs e) { string str = sliderCart.Text; var result = str.Substring(str.LastIndexOf(" ") + 1); var addProduct = new Product(); if (prod is ProductByQuantity) { ProductByQuantity temp = prod as ProductByQuantity; ProductByQuantity addProduct1 = new ProductByQuantity(temp.getUnitPrice(), (int)sliderC.Value, temp.Name, temp.Description, temp.ID); if (productInInventory(addProduct1) != -1) { adjust((int)sliderC.Value); Product temp1 = Home.ProductInventory[productInInventory(addProduct1)]; (temp1 as ProductByQuantity).addUnits((int)sliderC.Value); Home.ProductInventory[productInInventory(addProduct1)] = temp1; } else { adjust((int)sliderC.Value); Home.ProductInventory.Add(addProduct1); } } else { ProductByWeight temp = prod as ProductByWeight; ProductByWeight addProduct1 = new ProductByWeight(temp.getPricePerOunce(), (int)sliderC.Value, temp.Name, temp.Description, temp.ID); pr.Add(addProduct1); if (productInInventory(addProduct1) != -1) { adjust((int)sliderC.Value); Product temp1 = Home.ProductInventory[productInInventory(addProduct1)]; (temp1 as ProductByWeight).addOunces((int)sliderC.Value); Home.ProductInventory[productInInventory(addProduct1)] = temp1; } else { adjust((int)sliderC.Value); Home.ProductInventory.Add(addProduct1); } } //Home.checkout.update(); }
/// <summary> /// initializes the inventory list of products that the user will be available to use /// </summary> /// <param name="inv">passes the inv list by refernce so inv can be updated</param> static void LoadInv(ref List <Product> inv) { //Console.WriteLine("In Load inv"); Debug.Write("In Load inv"); ProductByWeight[] pw = new ProductByWeight[10]; ProductByQuantity[] pq = new ProductByQuantity[10]; for (int i = 0; i < 10; i++) { pw[i] = new ProductByWeight(); } for (int i = 0; i < 10; i++) { pq[i] = new ProductByQuantity(); } pw[0].Name = "Apples"; pw[0].Description = "Granny Smith Apple"; pw[0].PricePerOunce = 0.59; pw[0].ID = 1; pw[1].Name = "Bananas"; pw[1].Description = "Organic"; pw[1].PricePerOunce = 0.69; pw[1].ID = 2; pw[2].Name = "Tomatoes"; pw[2].Description = "Vine Ripe"; pw[2].PricePerOunce = 0.89; pw[2].ID = 3; pw[3].Name = "Potatos"; pw[3].Description = "Russet"; pw[3].PricePerOunce = 0.49; pw[3].ID = 4; pw[4].Name = "Sweet Potatos"; pw[4].Description = "Organic"; pw[4].PricePerOunce = 0.59; pw[4].ID = 5; pw[5].Name = "Asparagus"; pw[5].Description = "Organic"; pw[5].PricePerOunce = 0.79; pw[5].ID = 6; pw[6].Name = "Bell Peppers"; pw[6].Description = "Green"; pw[6].PricePerOunce = 0.69; pw[6].ID = 7; pw[7].Name = "Peaches"; pw[7].Description = "Sweet Georia"; pw[7].PricePerOunce = 0.59; pw[7].ID = 8; pw[8].Name = "Onions"; pw[8].Description = "Yellow"; pw[8].PricePerOunce = 0.39; pw[8].ID = 9; pw[9].Name = "Plum"; pw[9].Description = "Red"; pw[9].PricePerOunce = 0.49; pw[9].ID = 10; /////////////////////////////// pq[0].Name = "Cinnamon Toast Crunch"; pq[0].Description = "Kelogs Cereal"; pq[0].UnitPrice = 2.59; pq[0].ID = 11; pq[1].Name = "Frosted Flakes"; pq[1].Description = "Kelogs Cereal"; pq[1].UnitPrice = 2.39; pq[1].ID = 12; pq[2].Name = "Pop Tarts"; pq[2].Description = "Kelogs"; pq[2].UnitPrice = 3.59; pq[2].ID = 13; pq[3].Name = "Kombucha"; pq[3].Description = "GT Dave's"; pq[3].UnitPrice = 2.99; pq[3].ID = 14; pq[4].Name = "Cheese"; pq[4].Description = "Fresh Mozzarella"; pq[4].UnitPrice = 3.99; pq[4].ID = 15; pq[5].Name = "Eggs"; pq[5].Description = "1 Dozen"; pq[5].UnitPrice = 1.99; pq[5].ID = 16; pq[6].Name = "Bacon"; pq[6].Description = "12 Strips"; pq[6].UnitPrice = 4.49; pq[6].ID = 17; pq[7].Name = "Milk"; pq[7].Description = "1 Gallon"; pq[7].UnitPrice = 2.39; pq[7].ID = 18; pq[8].Name = "Orange Juice"; pq[8].Description = "Half Gallon"; pq[8].UnitPrice = 3.49; pq[8].ID = 19; pq[9].Name = "Bread"; pq[9].Description = "Pepperidge Farms Loaf"; pq[9].UnitPrice = 1.99; pq[9].ID = 20; foreach (var product in pw) { inv.Add(product); } foreach (var product in pq) { inv.Add(product); } }
public ProductViewModel(ObservableCollection <Product> ProductInventory1) { /*var jello = new ProductByQuantity(1.00, 10, "Jello", "Canned & Packaged Foods", 0001); * var ketchup = new ProductByQuantity(2.00, 20, "Ketchup", "Canned & Packaged Foods", 0002); * var mayonnaise = new ProductByQuantity(2.00, 35, "Mayonnaise", "Canned & Packaged Foods", 0003); * var chocolate = new ProductByQuantity(5.00, 25, "Chocolate bar", "Canned & Packaged Foods", 0004); * var paperTowels = new ProductByQuantity(3.50, 100, "Paper Towels", "Miscellaneous Kitchen Items", 0005); * var plasticWrap = new ProductByQuantity(2.35, 80, "Plastic Wrap", "Miscellaneous Kitchen Items", 0006); * var yougurt = new ProductByQuantity(1.50, 90, "Yougurt", "Refrigerated Foods", 0007); * var bagels = new ProductByQuantity(1.25, 150, "Bagels", "Bakery", 0008); * var bread = new ProductByQuantity(1.00, 200, "Bread", "Bakery", 0009); * var cereal = new ProductByQuantity(3.50, 45, "Cereal", "Breakfast", 0010); * * var bacon = new ProductByWeight(10.50, 130, "Bacon", "Refrigerated Foods", 0011); * var oranges = new ProductByWeight(5.50, 150, "Orange", "Produce", 0012); * var tomatoes = new ProductByWeight(4.25, 100, "Tomato", "Produce", 0013); * var beef = new ProductByWeight(15.75, 200, "Beef", "Produce", 0014); * var lemons = new ProductByWeight(3.50, 100, "Lemon", "Produce", 0015); * var chicken = new ProductByWeight(12.50, 75, "Chicken Breast", "Produce", 0016); * var cheese = new ProductByWeight(10.00, 150, "Cheese", "Refrigerated foods", 0017); * var apples = new ProductByWeight(3.50, 100, "Apple", "Produce", 0018); * var carrot = new ProductByWeight(3.00, 200, "Carrot", "Produce", 0019); * var lettuce = new ProductByWeight(20.00, 1000, "lettuce", "Produce", 0020); * * Inventory.Add(jello); Inventory.Add(ketchup); Inventory.Add(mayonnaise); Inventory.Add(chocolate); * Inventory.Add(paperTowels); Inventory.Add(plasticWrap); Inventory.Add(yougurt); Inventory.Add(bagels); * Inventory.Add(bread); Inventory.Add(cereal); Inventory.Add(bacon); Inventory.Add(oranges); * Inventory.Add(tomatoes); Inventory.Add(beef); Inventory.Add(lemons); Inventory.Add(chicken); * Inventory.Add(cheese); Inventory.Add(apples); Inventory.Add(carrot); Inventory.Add(lettuce);*/ readWriteJSON.write(); InventoryByQuantity = readWriteJSON.readByQuantity(); InventoryByWeight = readWriteJSON.ReadByWeight(); foreach (ProductByQuantity x in InventoryByQuantity) { ProductByQuantity prod = new ProductByQuantity(x.PriceSingle, x.Number, x.Name, x.Description, x.ID); Inventory.Add(prod); } foreach (ProductByWeight x in InventoryByWeight) { ProductByWeight prod = new ProductByWeight(x.PriceSingle, x.Number, x.Name, x.Description, x.ID); Inventory.Add(prod); } ProductInventory = ProductInventory1; foreach (Product prod in Inventory) { if (prod is ProductByQuantity) { if (((ProductByQuantity)prod).getUnits() > 0) { ProductInventory.Add(prod); } } else if (prod is ProductByWeight) { if (((ProductByWeight)prod).getOunces() > 0) { ProductInventory.Add(prod); } } } }