Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public PagedQueryArticleModelResponse PagedQueryArticleModels(PagedQueryArticleModelRequest request)
        {
            var page     = request.Page ?? 1;
            var pageSize = request.PageSize ?? 20;

            using (var client = DbFactory.CreateClient())
            {
                var total = 0;
                var list  = client.Queryable <ArticleModel>()
                            .WhereIF(!request.Keyword.IsNullOrEmpty(), t => t.Name.Contains(request.Keyword))
                            .Select(t => new QueryArticleModelItem()
                {
                    Id            = t.Id,
                    Name          = t.Name,
                    Configuration = t.Configuration,
                    CategoryId    = t.CategoryId,
                })
                            .OrderBy("id DESC")
                            .ToPageList(page, pageSize, ref total);
                return(new PagedQueryArticleModelResponse()
                {
                    List = list,
                    Page = page,
                    PageSize = pageSize,
                    TotalCount = total
                });
            }
        }
Пример #2
0
        public IActionResult PagedList(PagedQueryArticleModelRequest request)
        {
            var list   = _articleModelService.PagedQueryArticleModels(request);
            var result = new
            {
                Code    = 0,
                Message = "",
                Total   = list.TotalCount,
                Data    = list.List
            };

            return(Json(result));
        }