protected virtual async Task <IPagedList <Subscription> > InnerSearchSubscriptionsAsync(SubscriptionSearchCriteria criteria, WorkContext workContext) { if (criteria == null) { throw new ArgumentNullException(nameof(criteria)); } var result = await _subscriptionApi.SearchSubscriptionsAsync(criteria.ToSearchCriteriaDto()); return(new StaticPagedList <Subscription>(result.Subscriptions.Select(x => x.ToSubscription(workContext.AllCurrencies, workContext.CurrentLanguage)), criteria.PageNumber, criteria.PageSize, result.TotalCount.Value)); }
public async Task <IPagedList <Subscription> > SearchSubscriptionsAsync(SubscriptionSearchCriteria criteria) { var workContext = _workContextAccessor.WorkContext; var cacheKey = CacheKey.With(GetType(), "SearchSubscription", criteria.GetCacheKey()); return(await _memoryCache.GetOrCreateExclusiveAsync(cacheKey, async (cacheEntry) => { //Observe all subscriptions for current user and invalidate them in cache if any changed (one limitation - this toke doesn't detect subscriptions deletions) cacheEntry.AddExpirationToken(new PollingApiSubscriptionsChangeToken(_subscriptionApi, _options.ChangesPollingInterval)); cacheEntry.AddExpirationToken(SubscriptionCacheRegion.CreateCustomerSubscriptionChangeToken(criteria.CustomerId)); var result = await _subscriptionApi.SearchSubscriptionsAsync(criteria.ToSearchCriteriaDto()); return new StaticPagedList <Subscription>(result.Subscriptions.Select(x => x.ToSubscription(workContext.AllCurrencies, workContext.CurrentLanguage)), criteria.PageNumber, criteria.PageSize, result.TotalCount.Value); })); }