コード例 #1
0
        public async Task <ListResponse <ReviewsListItemDto> > ListAsync(ListReviewsRequest request)
        {
            var filter = _mapper.Map <ListReviewsRequest, ReviewsFilter>(request);
            var sort   = _mapper.Map <ListReviewsRequest, Sort>(request);
            var paging = _mapper.Map <ListReviewsRequest, Paging>(request);

            var reviews = await _reviewRepository.GetListAsync(filter, sort, paging);

            var reviewsCount = await _reviewRepository.CountAsync(filter);

            var reviewsDtosList = _mapper.Map <List <Review>, List <ReviewsListItemDto> >(reviews);

            return(new ListResponse <ReviewsListItemDto>(reviewsDtosList, reviewsCount));
        }
コード例 #2
0
        public async Task <IActionResult> List([FromQuery] ListReviewsRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }

            var response = await _reviewService.ListAsync(request);

            if (!response.IsValid)
            {
                return(BadRequest(response.Message));
            }
            return(Ok(response));
        }