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 UpdateArticle()
 {
     IArticleService articleService = new ArticleService();
     var model = new ArticleInfo();
     model.Id = Convert.ToInt32(HttpContext.Current.Request.Params["ArticleId"]);
     model.CategoryId = Convert.ToInt32(HttpContext.Current.Request.Params["ArticleCategoryId"]);
     model.Title = HttpContext.Current.Request.Params["Title"];
     model.SubTitle = HttpContext.Current.Request.Params["SubTitle"];
     model.Summary = HttpContext.Current.Request.Params["Summary"];
     model.Content = HttpContext.Current.Request.Params["Content"];
     model.Keywords = HttpContext.Current.Request.Params["Keywords"];
     model.MetaDesc = HttpContext.Current.Request.Params["MetaDesc"];
     model.Source = HttpContext.Current.Request.Params["Source"];
     model.AllowComments = true;//(int)HttpContext.Current.Request.Params["AllowComments"];
     model.Clicks = Convert.ToInt32(HttpContext.Current.Request.Params["Clicks"] ?? "0");
     model.ReadPassword = HttpContext.Current.Request.Params["ReadPassword"];
     model.UserId = 0;
     model.DisplayOrder = OrderGenerator.NewOrder();
     model.PublishDate = Convert.ToDateTime(HttpContext.Current.Request.Params["PublishDate"]);
     model.InDate = DateTime.Now;
     model.EditDate = DateTime.Now;
     model.FocusPicture = HttpContext.Current.Request.Params["FocusPicture"];
     return articleService.Update(model);
 }
 public int DeleteArticleById(int id)
 {
     IArticleService articleService = new ArticleService();
     return articleService.Delete(id);
 }
        public JQGridDataResult GetArticles()
        {
            // 每页显示记录数
            int pageSize = int.Parse(HttpContext.Current.Request.QueryString["rows"]);
            // 当前页
            int pageIndex = int.Parse(HttpContext.Current.Request.QueryString["page"]);

            IArticleService articleService = new ArticleService();
            var data= articleService.GetArticles(pageSize, pageIndex, string.Empty);

            // 记录总数
            int rowCount = data.TotalCount;
            // 总页数
            int pageCount = rowCount % pageSize == 0 ? rowCount / pageSize : rowCount / pageSize + 1;

            var resultObj = new JQGridDataResult
            {
                // 总页数
                PageCount = pageCount,
                // 当前页
                PageIndex = pageIndex,
                // 总记录数
                Total = rowCount,
                // 数据
                Data = data
            };
            return resultObj;
        }