Example #1
0
        public static void PopulateCategoryData(int sectionID)
        {
            if (sectionID > 0)
            {
                DataTable sectionTable = AdminSections.GetSection(sectionID);
                if (sectionTable.Rows.Count > 0)
                {
                    DataRow sectionRow  = sectionTable.Rows[0];
                    string  sectionName = sectionRow["CategoryName"].ToString(); //sectionRow["CategoryDesc"].ToString();

                    DataTable categoriesDataTable = AdminCategories.GetCategories(sectionID);
                    collection = new CategoryCollection();
                    collection.Add(new Category(sectionID, 0, sectionName));
                    foreach (DataRow categoryRow in categoriesDataTable.Rows)
                    {
                        collection.Add(new Category((int)categoryRow["CategoryID"], (int)categoryRow["ParentID"], categoryRow["CategoryName"].ToString()));
                    }
                }
            }
            else
            {
                DataTable categoriesDataTable = AdminCategories.GetCategories();
                collection = new CategoryCollection();
                foreach (DataRow categoryRow in categoriesDataTable.Rows)
                {
                    collection.Add(new Category((int)categoryRow["CategoryID"], (int)categoryRow["ParentID"], categoryRow["CategoryName"].ToString()));
                }
            }
        }
Example #2
0
        public override IHierarchicalEnumerable Select()
        {
            CategoryCollection collection = new CategoryCollection();

            foreach (Category category in Common.GetCategoryData())
            {
                if (category.ParentId == 0)
                {
                    collection.Add(category);
                }
            }

            return(collection);
        }
Example #3
0
        public IHierarchicalEnumerable GetChildren()
        {
            CategoryCollection children = new CategoryCollection();

            // Loop through your local data and find any children
            foreach (Category category in Common.GetCategoryData())
            {
                if (category.ParentId == this.CategoryId)
                {
                    children.Add(category);
                }
            }
            return(children);
        }
Example #4
0
        /// <summary>
        /// Wraper around local data cache to retrieve just root categories from the collection
        /// </summary>
        /// <returns>CategoryCollection containing just categories with a parentId of "root"</returns>
        public static CategoryCollection GetRootCategories(int sectionID)
        {
            CategoryCollection rootCategories = new CategoryCollection();

            PopulateCategoryData(sectionID);
            if (GetCategoryData() != null)
            {
                foreach (Category category in GetCategoryData())
                {
                    if (category.ParentId == 0)
                    {
                        rootCategories.Add(category);
                    }
                }
            }

            return(rootCategories);
        }