public async Task <IActionResult> GetDelinquencyReport(ReportResourceParameters parameters) { if (!ShapeExtensions.ArePropertiesValidFor <DelinquencySummary>(parameters.Fields)) { return(BadRequest()); } var reportData = await _repository.GetDelinquencySummaryReport(parameters); var previousPageLink = reportData.HasPrevious ? CreateReportResourceUri(parameters, parameters.PageNumber - 1) : null; var nextPageLink = reportData.HasNext ? CreateReportResourceUri(parameters, parameters.PageNumber + 1) : null; var paginationMetadata = new { previousPageLink = previousPageLink, nextPageLink = nextPageLink, totalCount = reportData.TotalCount, pageSize = reportData.PageSize, currentPage = reportData.CurrentPage, totalPages = reportData.TotalPages }; Response.Headers.Add("X-Pagination", System.Text.Json.JsonSerializer.Serialize(paginationMetadata)); var dtoResponse = _mapper.Map <IEnumerable <DelinquencySummaryDto> >(reportData); var reportResponse = new { data = dtoResponse.ShapeData(parameters.Fields), pagination = paginationMetadata }; return(Ok(reportResponse)); }