public static IList<ProductGroup> GetAllChildProductsGroup(ProductGroup prodGroup) { IList<ProductGroup> result = GetSubProductsGroups(prodGroup); foreach (ProductGroup prodGr in result) { IList<ProductGroup> subProd = GetAllChildProductsGroup(prodGr); result = result.Concat(subProd).ToList(); } return result; }
public static IList<Product> GetProducts(string productCode, string productName, ProductGroup productGroup, Manufacturer manufacturer) { var result = productRepository.GetQueryable().Where(p => p.Name.Contains(productName) && p.Code.Contains(productCode)).AsEnumerable(); if (manufacturer != null) { result = from p in result where p.Manufacturer == manufacturer select p; } if (productGroup != null) { IList<ProductGroup> allProductsGroups = GetAllChildProductsGroup(productGroup); allProductsGroups.Add(productGroup); var productGroupsId = from pG in allProductsGroups select pG.ProductGroupID; result = from p in result where productGroupsId.Contains(p.ProductGroup.ProductGroupID) select p; } return result.ToList(); }
public static IList<ProductGroup> GetSubProductsGroups(ProductGroup parent) { //if (prodGroupId == Guid.Empty) // return null; return productRepository.GetSubProductsGroups(parent); }