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 }); }
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)); }