Exemple #1
0
        public async Task <IActionResult> GetProductRatings(
            [FromRoute] int productId,
            [FromQuery] GetAllRatingsQuery query,
            [FromQuery] PaginationQuery paginationQuery,
            [FromQuery] SortQuery sortQuery)
        {
            var filter           = mapper.Map <GetAllRatingsFilter>(query);
            var sortingFilter    = sortingService.GetRatingSortingFilters(sortQuery);
            var paginationFilter = mapper.Map <PaginationFilter>(paginationQuery);
            var productQuery     = new GetRatingsQuery
            {
                ProductId  = productId,
                Filter     = filter,
                Pagination = paginationFilter,
                Sorting    = sortingFilter
            };

            var result = await mediator.Send(productQuery).ConfigureAwait(false);

            return(Ok(paginationService.CreateProductRatingsPaginatedResponse(productId,
                                                                              paginationFilter,
                                                                              filter,
                                                                              sortingFilter,
                                                                              result)));
        }