示例#1
0
        private Product[] FilterResultByCategory(Product[] products, string category)
        {
            if (category != "None")
            {
                LinkedList <Product> productsAfterFilter = new LinkedList <Product>();
                Category             cat = _storeLogic.GetCategoryByName(category);
                LinkedList <Product> categoryProducts = _storeLogic.GetAllCategoryProducts(cat.SystemId);
                foreach (var product in products)
                {
                    foreach (var categoryProduct in categoryProducts)
                    {
                        if (categoryProduct.Name == product.Name)
                        {
                            productsAfterFilter.AddLast(product);
                        }
                    }
                }
                return(productsAfterFilter.ToArray());
            }

            return(products);
        }