Exemplo n.º 1
0
        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();
        }