示例#1
0
        public async Task <PagedList <AuRecord> > GetAuRecordPaged(AuRecordParams auRecordParams)
        {
            var auRecords = _aurecordservicesrepository.GetEntitys();

            //auRecords = auRecords.Where(a => a.CategoryId == prProductParams.CategoryId && a.Name.Contains(prProductParams.Name));
            return(await PagedList <AuRecord> .CreatePagedList(auRecords, auRecordParams.PageSize, auRecordParams.PageNum));
        }
示例#2
0
        public async Task <ActionResult <IEnumerable <AuRecordDto> > > GetAuRecords([FromQuery] AuRecordParams auRecordParams)
        {
            var res  = new MessageModel <IEnumerable <AuRecordDto> >();
            var list = await _auRecordServices.GetAuRecordPaged(auRecordParams);

            string previousLink = list.HasPrevious ? CreateLink(PagedType.Previous, auRecordParams) : null;
            string nextLink     = list.HasNext ? CreateLink(PagedType.Next, auRecordParams) : 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 <AuRecordDto> >(list);
            return(Ok(res));
        }
示例#3
0
        private string CreateLink(PagedType pagedType, AuRecordParams auRecordParams)
        {
            switch (pagedType)
            {
            case PagedType.Previous:
                return(Url.Link(nameof(GetAuRecords), new
                {
                    PageNum = auRecordParams.PageNum - 1,
                    PageSize = auRecordParams.PageSize
                }));

            case PagedType.Next:
                return(Url.Link(nameof(GetAuRecords), new
                {
                    PageNum = auRecordParams.PageNum + 1,
                    PageSize = auRecordParams.PageSize
                }));
            }
            return(string.Empty);
        }