Exemplo n.º 1
0
        public static void AddPagination(this HttpResponse response,
                                         int currentPage, int itemsPerPage, int totalItems, int totalPages)
        {
            var paginationHeader = new PaginationHeader(currentPage, itemsPerPage,
                                                        totalItems, totalPages);
            var camelCaseFormatter = new JsonSerializerSettings();

            camelCaseFormatter.ContractResolver =
                new CamelCasePropertyNamesContractResolver();
            response.Headers.Add("Pagination",
                                 JsonConvert.SerializeObject(paginationHeader, camelCaseFormatter));
            response.Headers.Add("Access-Control-Expose-Headers", "Pagination");
        }
Exemplo n.º 2
0
        public static void AddPaginationHeader(this HttpResponse response, int currentPage,
                                               int itemsPerPage, int totalItems, int totalPages)
        {
            var paginationHeader = new PaginationHeader(currentPage, itemsPerPage, totalItems, totalPages);

            var options = new JsonSerializerOptions
            {
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase
            };

            response.Headers.Add("Pagination", JsonSerializer.Serialize(paginationHeader, options));
            response.Headers.Add("Access-Control-Expose-Headers", "Pagination");
        }