public static void AddPagination(this HttpResponse response, int currentPage, int itemsPerPage, int totalItems, int totalPages) { var paginationHeader = new PaginationHeader (currentPage, itemsPerPage, totalItems, totalPages); //response.Headers.Add("Application-Error",message); var camelCaseFormatter = new JsonSerializerSettings(); camelCaseFormatter.ContractResolver = new CamelCasePropertyNamesContractResolver(); response.Headers.Add("Pagination", JsonConvert.SerializeObject(paginationHeader, camelCaseFormatter)); response.Headers.Add("Access-Control-Expose-Headers", "Pagination"); //response.Headers.Add("Access-Control-All-Origin","*"); }
// will send this data by header response to clinet side public static void AddPagination(this HttpResponse response, int currentPage, int itemsPerPage, int totalItems, int totalPages) { var paginationHeader = new PaginationHeader(currentPage, itemsPerPage, totalItems, totalPages); // Constractor from class PaginationHeader // camelCaseFormatter this function is simple its just to change the format for parameter // from (title formal) => like this TitleFormat to (camel Format) => like this camelFormat var camelCaseFormatter = new JsonSerializerSettings(); camelCaseFormatter.ContractResolver = new CamelCasePropertyNamesContractResolver(); response.Headers.Add("Pagination", JsonConvert.SerializeObject(paginationHeader, camelCaseFormatter)); response.Headers.Add("Access-Control-Expose-Headers", "Pagination"); }
public static void AddPagination(this HttpResponse response, int totalPages, int totalItems, int currentPage, int pageSize) { var paginationHeader = new PaginationHeader(totalPages, totalItems, currentPage, pageSize); var camelCaseformatter = new JsonSerializerSettings(); camelCaseformatter.ContractResolver = new CamelCasePropertyNamesContractResolver(); response.Headers.Add("Pagination", JsonConvert.SerializeObject(paginationHeader, camelCaseformatter)); response.Headers.Add("Access-Control-Expose-Headers", "Pagination"); }