Beispiel #1
0
        public async Task <PagedList <PrProductMaterial> > GetPrProductMaterialPaged(PrProductMaterialParams prProductMaterialParams)
        {
            var prProductMaterials = _prproductmaterialrepository.GetEntitys();

            //auRecords = auRecords.Where(a => a.CategoryId == prProductParams.CategoryId && a.Name.Contains(prProductParams.Name));
            return(await PagedList <PrProductMaterial> .CreatePagedList(prProductMaterials, prProductMaterialParams.PageSize, prProductMaterialParams.PageNum));
        }
Beispiel #2
0
        private string CreateLink(PagedType pagedType, PrProductMaterialParams prProductMaterialParams)
        {
            switch (pagedType)
            {
            case PagedType.Previous:
                return(Url.Link(nameof(GetPrProductMaterials), new
                {
                    PageNum = prProductMaterialParams.PageNum - 1,
                    PageSize = prProductMaterialParams.PageSize
                }));

            case PagedType.Next:
                return(Url.Link(nameof(GetPrProductMaterials), new
                {
                    PageNum = prProductMaterialParams.PageNum + 1,
                    PageSize = prProductMaterialParams.PageSize
                }));
            }
            return(string.Empty);
        }
Beispiel #3
0
        public async Task <ActionResult <IEnumerable <PrProductMaterialDto> > > GetPrProductMaterials([FromQuery] PrProductMaterialParams prProductMaterialParams)
        {
            var res  = new MessageModel <IEnumerable <IcProductRecordDto> >();
            var list = await _prProductMaterialServices.GetPrProductMaterialPaged(prProductMaterialParams);

            string previousLink = list.HasPrevious ? CreateLink(PagedType.Previous, prProductMaterialParams) : null;
            string nextLink     = list.HasNext ? CreateLink(PagedType.Next, prProductMaterialParams) : 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 <IcProductRecordDto> >(list);
            return(Ok(res));
        }