protected async Task <int> GetTotalPages(
                ReportsQuery request,
                bool onlyApproved = true,
                int?reporterId    = default,
                CancellationToken cancellationToken = default)
            {
                var reportSpecification = this.GetReportSpecification(request, onlyApproved);

                var reporterSpecification = this.GetReporterSpecification(request, reporterId);

                var totalReports = await this.reportRepository.Total(
                    reportSpecification,
                    reporterSpecification,
                    cancellationToken);

                return((int)Math.Ceiling((double)totalReports / ReportsPerPage));
            }
            protected async Task <IEnumerable <TOutputModel> > GetReportListings <TOutputModel>(
                ReportsQuery request,
                bool onlyApproved = true,
                int?reporterId    = default,
                CancellationToken cancellationToken = default)
            {
                var reportSpecification = this.GetReportSpecification(request, onlyApproved);

                var reporterSpecification = this.GetReporterSpecification(request, reporterId);

                var searchOrder = new ReportsSortOrder(request.SortBy, request.Order);

                var skip = (request.Page - 1) * ReportsPerPage;

                return(await this.reportRepository.GetReportListings <TOutputModel>(
                           reportSpecification,
                           reporterSpecification,
                           searchOrder,
                           skip,
                           take : ReportsPerPage,
                           cancellationToken));
            }
 private Specification <Reporter> GetReporterSpecification(ReportsQuery request, int?reporterId)
 => new ReporterByIdSpecification(reporterId)
 .And(new ReporterByNameSpecification(request.Reporter));
 private Specification <Report> GetReportSpecification(ReportsQuery request, bool onlyApproved)
 => new ReportByPetSpecification(request.Pet)
 .And(new ReportOnlyApprovedSpecification(onlyApproved));