public async Task <PagedList <IcCommodityStock> > IcCommodityStockPaged(IcCommodityStockParams icCommodityStockParams) { IQueryable <IcCommodityStock> pusupplierinfo = _iiccommoditystockrepository.GetEntitys(); if (icCommodityStockParams.WarehouseId != 0) { pusupplierinfo = pusupplierinfo.Where(a => a.WarehouseId == icCommodityStockParams.WarehouseId); } return(await PagedList <IcCommodityStock> .CreatePagedList(pusupplierinfo, icCommodityStockParams.PageSize, icCommodityStockParams.PageNum)); }
private string CreateLink(PagedType pagedType, IcCommodityStockParams puSupplierParams) { switch (pagedType) { case PagedType.Previous: return(Url.Link(nameof(IcCommodityStockPaged), new { PageNum = puSupplierParams.PageNum - 1, PageSize = puSupplierParams.PageSize })); case PagedType.Next: return(Url.Link(nameof(IcCommodityStockPaged), new { PageNum = puSupplierParams.PageNum + 1, PageSize = puSupplierParams.PageSize })); } return(string.Empty); }
public async Task <ActionResult <ActionResult <IEnumerable <IcCommodityStockDto> > > > IcCommodityStockPaged( [FromQuery] IcCommodityStockParams puSupplierParams) { var res = new MessageModel <IEnumerable <IcCommodityStockDto> >(); PagedList <IcCommodityStock> list = await _Iccommoditystockservices.IcCommodityStockPaged(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 <IcCommodityStockDto> >(list); return(Ok(res)); }