Exemplo n.º 1
0
        public static void PopulateCategoryData(int sectionID)
        {
            if (sectionID > 0)
            {
                DataTable sectionTable = FrontSections.GetSection(sectionID);
                DataRow   sectionRow   = sectionTable.Rows[0];
                string    sectionName  = sectionRow["CategoryName"].ToString();

                DataTable categoriesDataTable = FrontSections.GetSubCategories(sectionID);
                collection = new CategoryCollection();
                collection.Add(new Category(1, 0, sectionName, "/", sectionID));
                foreach (DataRow categoryRow in categoriesDataTable.Rows)
                {
                    collection.Add(new Category((int)categoryRow["CategoryID"], (int)categoryRow["ParentID"], categoryRow["CategoryName"].ToString(),
                                                "/Categories/Category.aspx?CategoryID=" + (int)categoryRow["CategoryID"], (int)categoryRow["SectionID"]));
                }
            }
            else
            {
                DataTable categoriesDataTable = FrontSections.GetAllCategories();
                collection = new CategoryCollection();
                foreach (DataRow categoryRow in categoriesDataTable.Rows)
                {
                    collection.Add(new Category((int)categoryRow["CategoryID"], (int)categoryRow["ParentID"], categoryRow["CategoryName"].ToString(),
                                                "/Categories/Category.aspx?CategoryID=" + (int)categoryRow["CategoryID"], (int)categoryRow["SectionID"]));
                }
            }
        }
Exemplo n.º 2
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);
            foreach (Category category in GetCategoryData())
            {
                if (category.ParentId == 0)
                {
                    rootCategories.Add(category);
                }
            }
            return(rootCategories);
        }
Exemplo n.º 3
0
        public override IHierarchicalEnumerable Select()
        {
            CategoryCollection collection = new CategoryCollection();

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

            return(collection);
        }
Exemplo n.º 4
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);
        }