예제 #1
0
        protected virtual Task LoadProductCustomerReviewsAsync(List <Product> products, WorkContext workContext)
        {
            if (products == null)
            {
                throw new ArgumentNullException(nameof(products));
            }

            foreach (var product in products)
            {
                product.CustomerReviews = new MutablePagedList <Model.CustomerReviews.CustomerReview>((pageNumber, pageSize, sortInfos, @params) =>
                {
                    var criteria = new CustomerReviewSearchCriteria()
                    {
                        PageNumber = pageNumber,
                        PageSize   = pageSize,
                        ProductIds = new[] { product.Id },
                        Sort       = SortInfo.ToString(sortInfos)
                    };
                    return(_customerReviewService.GetCustomerReviews(criteria));
                }, 1, CustomerReviewSearchCriteria.DefaultPageSize);
            }
            return(Task.CompletedTask);
        }