public ActionResult GetPageData(int page = 1, int size = 10, string kw = "") { Expression <Func <PostMergeRequest, bool> > where = r => true; if (!string.IsNullOrEmpty(kw)) { where = where.And(r => r.Title.Contains(kw) || r.Content.Contains(kw) || r.Modifier.Contains(kw) || r.ModifierEmail.Contains(kw)); } var list = PostMergeRequestService.GetQuery(where).OrderByDescending(d => d.MergeState == MergeStatus.Pending).ThenByDescending(r => r.Id).ToPagedList <PostMergeRequest, PostMergeRequestDtoBase>(page, size, MapperConfig); return(Ok(list)); }
public ActionResult GetPageData(int page = 1, int size = 10, string kw = "") { Expression <Func <PostMergeRequest, bool> > where = r => true; if (!string.IsNullOrEmpty(kw)) { where = where.And(r => r.Title.Contains(kw) || r.Content.Contains(kw) || r.Modifier.Contains(kw) || r.ModifierEmail.Contains(kw)); } var list = PostMergeRequestService.GetQuery(where).OrderBy(d => d.MergeState).ThenByDescending(r => r.Id).Skip((page - 1) * size).Take(size).ProjectTo <PostMergeRequestOutputDtoBase>(MapperConfig).ToList(); var count = PostMergeRequestService.Count(where); var pageCount = Math.Ceiling(count * 1.0 / size).ToInt32(); return(PageResult(list, pageCount, count)); }