コード例 #1
0
        public static PagedResponse <T> CreatePaginatedResponse <T>(IUriService uriService, PaginationFilter pagination, List <T> response)
        {
            var nextPage = pagination.PageNumber >= 1
               ? uriService.GetAllProductsUri(new PaginationQuery(pagination.PageNumber + 1, pagination.PageSize)).ToString()
               : null;

            var previousPage = pagination.PageNumber - 1 >= 1
                ? uriService.GetAllProductsUri(new PaginationQuery(pagination.PageNumber - 1, pagination.PageSize)).ToString()
                : null;

            return(new PagedResponse <T>
            {
                Data = response,
                PageNumber = pagination.PageNumber >= 1 ? pagination.PageNumber : (int?)null,
                PageSize = pagination.PageSize >= 1 ? pagination.PageSize : (int?)null,
                NextPage = response.Any() ? nextPage : null,
                PreviousPage = previousPage
            });
        }
コード例 #2
0
ファイル: PaginationService.cs プロジェクト: Shystee/Shop
        public PagedResponse <ProductResponse> CreateProductPaginatedResponse(
            PaginationFilter pagination,
            GetAllProductsFilter filter,
            SortingFilter sorting,
            List <ProductResponse> response)
        {
            var nextPage = pagination.PageNumber >= 1
                    ? uriService
                           .GetAllProductsUri(new PaginationQuery(pagination.PageNumber + 1, pagination.PageSize),
                                              filter,
                                              sorting)
                           .ToString()
                    : null;

            var previousPage = pagination.PageNumber - 1 >= 1
                    ? uriService
                               .GetAllProductsUri(new PaginationQuery(pagination.PageNumber - 1, pagination.PageSize),
                                                  filter,
                                                  sorting)
                               .ToString()
                    : null;

            return(CreatePaginatedResponse(pagination, sorting, response, nextPage, previousPage));
        }