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); }
public int UpdateArticleCategoryByCategoryId() { IArticleCategoryService articleCategoryService = new ArticleCategoryService(); var model = new ArticleCategoryInfo(); model.Id = Convert.ToInt32(HttpContext.Current.Request.Params["ArticleCategoryId"]); model.Title = HttpContext.Current.Request.Params["ArticleCategoryTitle"]; model.Name = HttpContext.Current.Request.Params["ArticleCategoryTitle"]; model.UrlPath = HttpContext.Current.Request.Params["UrlPath"]; model.Keywords = HttpContext.Current.Request.Params["ArticleCategoryKeywords"]; model.MetaDesc = HttpContext.Current.Request.Params["ArticleCategoryMetaDesc"]; //var parentId = HttpContext.Current.Request.Params["ParentArticleCategory"] ?? "0"; //model.ParentId = Convert.ToInt32(parentId); model.Description = HttpContext.Current.Request.Params["ArticleCategoryDesc"]; //model.InUserId = 0; //model.InDate = DateTime.Now; model.EditDate = DateTime.Now; model.EditUserId = 0; //model.DisplayOrder = OrderGenerator.NewOrder(); //model.DataStatus = 1; return articleCategoryService.Update(model); }
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 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; }