예제 #1
0
 public ArticleListRS GetArticles(ArticleListRQ rq)
 {
     if (rq == null || rq.pageIndex <= 0 || rq.pageSize <= 0)
     {
         return new ArticleListRS {
                    total = 0, list = null
         }
     }
     ;
     return(_service.GetArticles(rq));
 }
예제 #2
0
        /// <summary>
        /// 资讯管理列表
        /// </summary>
        /// <param name="rq"></param>
        /// <returns></returns>
        public ArticleListRS GetArticles(ArticleListRQ rq)
        {
            var result = new ArticleListRS {
                total = 0, list = null
            };
            var sql = string.Empty;//"select * from Article where 1=1 ";

            if (!string.IsNullOrWhiteSpace(rq.paraName))
            {
                sql += string.Format(" (ArticleTitle like '%{0}%' or ArticleType like '%{0}%') ", rq.paraName);
            }
            var user  = Article.FindAll(sql, "Id desc", null, (rq.pageIndex - 1) * rq.pageSize, rq.pageSize);
            var query = (from a in user.ToList()
                         select new
            {
                a.ArticleContent,
                a.ArticleImg,
                a.ArticleTitle,
                a.ArticleType,
                a.CreatedByName,
                a.CreatedOn,
                a.Id,
                a.IsPublish,
                a.IsRecommand,
                a.ModifiedByName,
                a.ModifiedOn,
                a.Status,
            });

            query        = query.OrderByDescending(q => q.ModifiedOn).ThenByDescending(q => q.Id);
            result.total = Article.FindAll(sql, null, null, 0, 0).Count;//query.Count();
            if (result.total == 0)
            {
                return(result);
            }
            result.list = query.Select(a => new ArticleListItemRS
            {
                Id             = a.Id,
                ArticleContent = a.ArticleContent,
                ArticleImg     = a.ArticleImg,
                ArticleType    = a.ArticleType,
                ArticleTitle   = a.ArticleTitle,
                IsPublish      = a.IsPublish,
                IsRecommand    = a.IsRecommand,
                Status         = a.Status,
                CreatedOn      = a.CreatedOn,
                CreatedByName  = a.CreatedByName
            }).ToList();
            return(result);
        }