Пример #1
0
        static void Main(string[] args)
        {
            try
            {
                List <Product> products = ProductsList.GetAllProducts();

                NewProduct(products);
                //Search products by category // return all products from given category
                List <Product> itEquipment = SearchProduct(Category.ItEquipment, products);
                List <Product> lapTop      = SearchProduct(Category.LapTop, products);
                List <Product> pc          = SearchProduct(Category.PC, products);
                List <Product> tv          = SearchProduct(Category.TV, products);

                //Filter products by price range(from min to max) // return all products that fall in the given price range
                FilterProducPrice(100000, products);

                //Find products by part of name // get all products that consist the part in their names
                SearchByPartOfName("gaming", products);

                //Get only products ids // return only the ids of the products
                GetProductId("Keyboard", products);

                //Get product price // get the price of the product - give the id as parameter
                GetProductPrice(20, products);

                //Get cheapest product // return the cheapest product
                GetCheapestProduct(products);

                //Get most expensive product // return the most expensive one
                GetMostExpensiveProduct(products);

                //Add product // create method to add product to the list of products
                Product product1 = new Product()
                {
                    Name = "Fuego", Price = 6000, Category = Category.TV
                };
                Product product2 = new Product()
                {
                    Name = "HP Pavilion", Price = 41990, Category = Category.LapTop
                };
                AddProduct(product1, products);
                AddProduct(product2, products);
                //Remove product // and a method to remove it - use id as parameter
                RemoveProduct(22, products);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }