Ejemplo n.º 1
0
        private void ApplicationBarIconButton_Click_1(object sender, EventArgs e)
        {
            ProductEqualityComparer pc = new ProductEqualityComparer();
            var productToAdd           = new Product(App.ViewModel.SelectedProduct);

            if (App.Cart.Contains(productToAdd, pc))
            {
                int index = 0;
                foreach (Product product in App.Cart)
                {
                    if (productToAdd.title == App.Cart[index].title)
                    {
                        App.Cart[index].quantity += 1;
                        break;
                    }

                    index++;
                }
            }
            else
            {
                productToAdd.quantity = 1;
                App.Cart.Add(productToAdd);    /* Add item to cart */
            }


            MessageBox.Show("Added " + productToAdd.title + " to cart.");
            NavigationService.Navigate(new Uri("/SubcategoriesPage.xaml", UriKind.Relative));
        }
Ejemplo n.º 2
0
        public void PopulateProductDB()
        {
            /* I'm having an error right now where each time I run the application I'm putting all of these Products in the database again... :( */
            /* Start by creating a list of Products. We'll actually insert them into the database later */
            ProductEqualityComparer pc = new ProductEqualityComparer();
            List <Product>          ProductInventory = new List <Product>();

            if (!App.GlobalVars.DBHasBeenPopulated)
            {
                #region Hats
                ProductInventory.Add(new Product()
                {
                    title = "Black Hat", imageUrl = "/Images/BlackHat.jpg", subcategory = "Hats", price = 19.99, quantity = 30
                });
                ProductInventory.Add(new Product()
                {
                    title = "Gray Hat", imageUrl = "/Images/GrayHat.jpg", subcategory = "Hats", price = 19.99, quantity = 30
                });
                ProductInventory.Add(new Product()
                {
                    title = "Crimson Hat", imageUrl = "/Images/Hats.jpg", subcategory = "Hats", price = 19.99, quantity = 40
                });
                ProductInventory.Add(new Product()
                {
                    title = "Beanie", imageUrl = "/Images/Men_Beanie.jpg", subcategory = "Hats", price = 14.99, quantity = 50
                });
                ProductInventory.Add(new Product()
                {
                    title = "Tie Up Beanie", imageUrl = "/Images/TieUpBeanie.jpg", subcategory = "Hats", price = 14.99, quantity = 50
                });
                ProductInventory.Add(new Product()
                {
                    title = "Visor", imageUrl = "/Images/Visor.jpg", subcategory = "Hats", price = 10, quantity = 1
                });
                #endregion

                #region Men
                ProductInventory.Add(new Product()
                {
                    title = "Black Polo", imageUrl = "/Images/BlackPolo.jpg", subcategory = "Men", price = 39.99, quantity = 25
                });
                ProductInventory.Add(new Product()
                {
                    title = "Jersey", imageUrl = "/Images/Men_Jersey.jpg", subcategory = "Men", price = 65.99, quantity = 50
                });
                ProductInventory.Add(new Product()
                {
                    title = "T-Shirt", imageUrl = "/Images/Men_Tshirt.jpg", subcategory = "Men", price = 14.99, quantity = 50
                });
                #endregion

                #region Women
                ProductInventory.Add(new Product()
                {
                    title = "V-neck", imageUrl = "/Images/Women.jpg", subcategory = "Women", price = 14.99, quantity = 1
                });
                ProductInventory.Add(new Product()
                {
                    title = "Hooded Sweatshirt", imageUrl = "/Images/Women_Hoodie.jpg", subcategory = "Women", price = 14.99, quantity = 50
                });
                ProductInventory.Add(new Product()
                {
                    title = "Jersey", imageUrl = "/Images/Women_Jersey.jpg", subcategory = "Women", price = 14.99, quantity = 50
                });
                ProductInventory.Add(new Product()
                {
                    title = "Long Sleeve Tee", imageUrl = "/Images/Women_LongSleeve.jpg", subcategory = "Women", price = 14.99, quantity = 50
                });
                ProductInventory.Add(new Product()
                {
                    title = "Women's Athletic Pants", imageUrl = "/Images/Women_PerformancePants.jpg", subcategory = "Women", price = 24.99, quantity = 50
                });
                ProductInventory.Add(new Product()
                {
                    title = "V-neck", imageUrl = "/Images/Women_VNeck.jpg", subcategory = "Women", price = 14.99, quantity = 50
                });
                #endregion

                #region Performance Apparel
                ProductInventory.Add(new Product()
                {
                    title = "Black Golf Shirt", imageUrl = "/Images/BlackPolo.jpg", subcategory = "PerformanceApparel", price = 39.99, quantity = 25
                });
                ProductInventory.Add(new Product()
                {
                    title = "Athletic Shorts", imageUrl = "/Images/Men_Shorts.jpg", subcategory = "PerformanceApparel", price = 29.99, quantity = 30
                });
                ProductInventory.Add(new Product()
                {
                    title = "Athletic Shorts", imageUrl = "/Images/PerformanceApparel.jpg", subcategory = "PerformanceApparel", price = 29.99, quantity = 30
                });
                ProductInventory.Add(new Product()
                {
                    title = "Women's Athletic Pants", imageUrl = "/Images/Women_PerformancePants.jpg", subcategory = "PerformanceApparel", price = 24.99, quantity = 50
                });
                #endregion

                /* Add the products to the database */
                foreach (Product product in ProductInventory)
                {
                    if (!InventoryDB.Inventory.Contains <Product>(product))
                    {
                        AddProduct(product);
                    }
                }

                InventoryDB.SubmitChanges();
            }

            App.GlobalVars.DBHasBeenPopulated = true;
        }