示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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));
        }