Пример #1
0
        public async Task <IPagedList <Model.CustomerReviews.CustomerReview> > SearchReviewsAsync(CustomerReviewSearchCriteria criteria)
        {
            var cacheKey = CacheKey.With(GetType(), nameof(SearchReviewsAsync), criteria.GetCacheKey());

            return(await _memoryCache.GetOrCreateExclusiveAsync(cacheKey, async (cacheEntry) =>
            {
                cacheEntry.AddExpirationToken(CustomerReviewCacheRegion.CreateChangeToken());
                cacheEntry.AddExpirationToken(_apiChangesWatcher.CreateChangeToken());
                var result = await _customerReviewsApi.SearchCustomerReviewsAsync(criteria.ToSearchCriteriaDto());
                return new StaticPagedList <Model.CustomerReviews.CustomerReview>(result.Results.Select(x => x.ToCustomerReview()),
                                                                                  criteria.PageNumber, criteria.PageSize, result.TotalCount.Value);
            }));
        }
        public async Task <Model.CustomerReviews.CustomerReview[]> SearchCustomerReviewsAsync(CustomerReviewSearchCriteria criteria)
        {
            var result = (await _customerReviewsApi.SearchCustomerReviewsAsync(criteria.ToSearchCriteriaDto()));

            return(result.Results.Select(x => x.ToCustomerReview()).ToArray());
        }