void BindSubCategories(int parentId) { foreach (Category childCat in GetChildCategories(parentId)) { _SortedCats.Add(new Category(DisplayIndent() + childCat.Name, childCat.Id)); _CatIndent++; BindSubCategories(childCat.Id); _CatIndent--; } }
public CategoryCollection GetCategoryTreeByProjectId(int projectId) { _SortedCats = new CategoryCollection(); _UnSortedCats = Category.GetCategoryByProjectId(projectId); foreach (Category parentCat in GetTopLevelCategories()) { _SortedCats.Add(parentCat); BindSubCategories(parentCat.Id); } return(_SortedCats); }
CategoryCollection GetChildCategories(int parentId) { CategoryCollection colCats = new CategoryCollection(); foreach (Category cat in _UnSortedCats) { if (cat.ParentCategoryId == parentId) { colCats.Add(cat); } } return(colCats); }
CategoryCollection GetTopLevelCategories() { CategoryCollection colCats = new CategoryCollection(); foreach (Category cat in _UnSortedCats) { if (cat.ParentCategoryId == 0) { colCats.Add(cat); } } return(colCats); }