public static void AddPaginationHeaders(this HttpResponse response, PaginationHeaders paginationHeaders) { response.Headers.Add("Page", paginationHeaders.Page.ToString()); response.Headers.Add("PerPage", paginationHeaders.PerPage.ToString()); response.Headers.Add("TotalItems", paginationHeaders.TotalItems.ToString()); response.Headers.Add("TotalPages", paginationHeaders.TotalPages.ToString()); }
public static void Headers(this HttpResponse httpresponse, int totalCount, int totalPage, int currentPage, int itemsPerPage) { var paginationHeaders = new PaginationHeaders(totalCount, totalPage, currentPage, itemsPerPage); var camelCaseFormatter = new JsonSerializerSettings(); camelCaseFormatter.ContractResolver = new CamelCasePropertyNamesContractResolver(); httpresponse.Headers.Add("paginationHeaders", JsonConvert.SerializeObject(paginationHeaders, camelCaseFormatter)); httpresponse.Headers.Add("Access-Control-Expose-Headers", "paginationHeaders"); }
public static void AddPagination(this HttpResponse response, int currentPage, int totalPages, int pageSize, int totalItems) { var paginationHeader = new PaginationHeaders(currentPage, totalPages, pageSize, totalItems); var camelCaseFormatter = new JsonSerializerSettings(); camelCaseFormatter.ContractResolver = new CamelCasePropertyNamesContractResolver(); response.Headers.Add("Pagination", JsonConvert.SerializeObject(paginationHeader)); response.Headers.Add("Access-Control-Expose-Header", "Pagination"); }
public static void AddPaginationHeader(this HttpResponse response, int currentPage, int itemsPerPage, int totalItems, int totalPages) { var paginationHeader = new PaginationHeaders(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"); }