示例#1
0
        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);
                }
            }
        }
示例#2
0
        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);
        }