コード例 #1
0
            protected async Task <int> GetTotalPages(
                ReviewsQuery request,
                int?reviewId = default,
                CancellationToken cancellationToken = default)
            {
                var reviewSpecification = this.GetReviewSpecification(request, reviewId);

                var totalReviews = await this.reviewRepository.Total(
                    reviewSpecification,
                    cancellationToken);

                return((int)Math.Ceiling((double)totalReviews / ReviewsPerPage));
            }
コード例 #2
0
            protected async Task <IEnumerable <TOutputModel> > GetReviewListings <TOutputModel>(
                ReviewsQuery request,
                int?reviewId = default,
                CancellationToken cancellationToken = default)
            {
                var reviewSpecification = this.GetReviewSpecification(request, reviewId);

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

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

                return(await this.reviewRepository.GetReviewListings <TOutputModel>(
                           reviewSpecification,
                           searchOrder,
                           skip,
                           take : ReviewsPerPage,
                           cancellationToken));
            }
コード例 #3
0
 private Specification <Review> GetReviewSpecification(ReviewsQuery request, int?reviewId)
 => new ReviewByIdSpecification(reviewId)
 .And(new ReviewByTitleSpecification(request.Title));