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)); }
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)); }
private Specification <Review> GetReviewSpecification(ReviewsQuery request, int?reviewId) => new ReviewByIdSpecification(reviewId) .And(new ReviewByTitleSpecification(request.Title));