public async Task <PagedList <PuOrder> > PuOrderPaged(PuOrderParams puOrderParams) { IQueryable <PuOrder> pusupplierinfo = _puorderrepository.GetEntitys(); if (!string.IsNullOrWhiteSpace(puOrderParams.No)) { pusupplierinfo = pusupplierinfo.Where(a => a.No.Contains(puOrderParams.No)); } return(await PagedList <PuOrder> .CreatePagedList(pusupplierinfo, puOrderParams.PageSize, puOrderParams.PageNum)); }
private string CreateLink(PagedType pagedType, PuOrderParams puSupplierParams) { switch (pagedType) { case PagedType.Previous: return(Url.Link(nameof(PuOrderPaged), new { PageNum = puSupplierParams.PageNum - 1, PageSize = puSupplierParams.PageSize })); case PagedType.Next: return(Url.Link(nameof(PuOrderPaged), new { PageNum = puSupplierParams.PageNum + 1, PageSize = puSupplierParams.PageSize })); } return(string.Empty); }
public async Task <ActionResult <ActionResult <IEnumerable <PuOrderDto> > > > PuOrderPaged( [FromQuery] PuOrderParams puSupplierParams) { var res = new MessageModel <IEnumerable <PuOrderDto> >(); PagedList <PuOrder> list = await _puorderservices.PuOrderPaged(puSupplierParams); string previousLink = list.HasPrevious ? CreateLink(PagedType.Previous, puSupplierParams) : null; string nextLink = list.HasNext ? CreateLink(PagedType.Next, puSupplierParams) : null; var pagination = new { currentPage = list.PageNum, totalPage = list.TotalPage, totalCount = list.TotalCount, previousLink, nextLink }; HttpContext.Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(pagination)); res.Data = _mapper.Map <IEnumerable <PuOrderDto> >(list); return(Ok(res)); }