private static void LoadSubCategorys(int parentCategoryId, IList <CategoryInfo> categories) { IEnumerable <CategoryInfo> subCategories = CatalogHelper.GetSubCategories(parentCategoryId); if (subCategories != null) { foreach (CategoryInfo item in subCategories) { categories.Add(item); CatalogHelper.LoadSubCategorys(item.CategoryId, categories); } } }
public static IList <CategoryInfo> GetSequenceCategories(string categoryname = "") { IList <CategoryInfo> list = null; if (!string.IsNullOrEmpty(categoryname)) { CategoriesQuery categoriesQuery = new CategoriesQuery(); categoriesQuery.Name = categoryname; list = CatalogHelper.GetCategoryList(categoriesQuery); } else { list = new List <CategoryInfo>(); IEnumerable <CategoryInfo> mainCategories = CatalogHelper.GetMainCategories(); foreach (CategoryInfo item in mainCategories) { list.Add(item); CatalogHelper.LoadSubCategorys(item.CategoryId, list); } } return(list); }