Ejemplo n.º 1
0
        public async Task <PagedList <QmCommodity> > QmCommodityPaged(QmCommodityParams qmCommodityParams)
        {
            IQueryable <QmCommodity> pusupplierinfo = _qmcommodityrepository.GetEntitys();

            if (!string.IsNullOrWhiteSpace(qmCommodityParams.No))
            {
                pusupplierinfo = pusupplierinfo.Where(a => a.No.Contains(qmCommodityParams.No));
            }
            return(await PagedList <QmCommodity> .CreatePagedList(pusupplierinfo, qmCommodityParams.PageSize, qmCommodityParams.PageNum));
        }
Ejemplo n.º 2
0
        private string CreateLink(PagedType pagedType, QmCommodityParams puSupplierParams)
        {
            switch (pagedType)
            {
            case PagedType.Previous:
                return(Url.Link(nameof(QmCommodityPaged), new
                {
                    PageNum = puSupplierParams.PageNum - 1,
                    PageSize = puSupplierParams.PageSize
                }));

            case PagedType.Next:
                return(Url.Link(nameof(QmCommodityPaged), new
                {
                    PageNum = puSupplierParams.PageNum + 1,
                    PageSize = puSupplierParams.PageSize
                }));
            }
            return(string.Empty);
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <ActionResult <IEnumerable <QmCommodityDto> > > > QmCommodityPaged(
            [FromQuery] QmCommodityParams puSupplierParams)
        {
            var res = new MessageModel <IEnumerable <QmCommodityDto> >();
            PagedList <QmCommodity> list = await _qmcommodityservices.QmCommodityPaged(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 <QmCommodityDto> >(list);
            return(Ok(res));
        }