Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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));
        }