public List <ArticleCategoryInfo> GetAllArticleCategory() { IArticleCategoryService articleCategoryService = new ArticleCategoryService(); var data = articleCategoryService.GetAllArticleCategory().Where(s => s.Depth != 0).ToList(); var group = ConfigHelper.ListConfig.GetListItems("ArticleCategoryType"); data.ForEach((s) => { s.TypeName = group.FirstOrDefault(item => item.Value == s.CategoryType.ToString()).Text; }); return(data); }
public List <ComboTree> GetComboTreeArticleCategory(int id) { IArticleCategoryService articleCategoryService = new ArticleCategoryService(); var data = articleCategoryService.GetAllArticleCategory(); List <ComboTree> result = new List <ComboTree>(); var root = data.Where(s => s.Depth == id); foreach (var articleCategoryInfo in root) { var comboTree = new ComboTree(); comboTree.Id = articleCategoryInfo.Id; comboTree.Text = articleCategoryInfo.Name; comboTree.Children = GetComboTreeChildren2(comboTree, articleCategoryInfo, data); result.Add(comboTree); } return(result); }
public int DeleteArticleCategoryById(int id) { // 删除栏目的同时 删除栏目下属的文章 IArticleCategoryService articleCategoryService = new ArticleCategoryService(); var articleCategory = articleCategoryService.GetArticleCategoryById(id); if (articleCategory != null) { IArticleService articleService = new ArticleService(); //WHERE Lft BETWEEN @MyLeft AND @MyRight; var all = articleCategoryService.GetAllArticleCategory().Where(s => s.Lft >= articleCategory.Lft && s.Lft <= articleCategory.Rgt); foreach (ArticleCategoryInfo articleCategoryInfo in all) { articleService.DeleteByCategoryId(articleCategory.Id); } } return(articleCategoryService.Delete(id)); }