public static string GetCategoryBreadCrumb(this ArticleCategory category, IArticleCategoryService categoryService, IDictionary <int, ArticleCategory> mappedCategories = null) { string result = string.Empty; while (category != null && !category.Deleted) { // codehint: sm-edit if (String.IsNullOrEmpty(result)) { result = category.GetFullCategoryName(); } else { result = category.GetFullCategoryName() + " >> " + result; } int parentId = category.ParentCategoryId; if (mappedCategories == null) { category = categoryService.GetArticleCategoryById(parentId); } else { category = mappedCategories.ContainsKey(parentId) ? mappedCategories[parentId] : categoryService.GetArticleCategoryById(parentId); } } return(result); }
public static string GetCategoryNameWithPrefix(this ArticleCategory category, IArticleCategoryService categoryService, IDictionary <int, ArticleCategory> mappedCategories = null) { string result = string.Empty; while (category != null) { if (String.IsNullOrEmpty(result)) { result = category.GetFullCategoryName(); } else { result = "--" + result; } int parentId = category.ParentCategoryId; if (mappedCategories == null) { category = categoryService.GetArticleCategoryById(parentId); } else { category = mappedCategories.ContainsKey(parentId) ? mappedCategories[parentId] : categoryService.GetArticleCategoryById(parentId); } } return(result); }