protected virtual IMutablePagedList <Subscription> GetCustomerSubscriptions(CustomerInfo customer) { var workContext = _workContextFactory(); var subscriptionSearchcriteria = new subscriptionDto.SubscriptionSearchCriteria { CustomerId = customer.Id, ResponseGroup = SubscriptionResponseGroup.Full.ToString() }; Func <int, int, IEnumerable <SortInfo>, IPagedList <Subscription> > subscriptionGetter = (pageNumber, pageSize, sortInfos) => { subscriptionSearchcriteria.Skip = (pageNumber - 1) * pageSize; subscriptionSearchcriteria.Take = pageSize; var cacheKey = "GetSubscriptions-" + subscriptionSearchcriteria.GetHashCode(); var retVal = _cacheManager.Get(cacheKey, string.Format(_customerSubscriptionCacheRegionFormat, customer.Id), () => { var searchResult = _subscriptionApi.SubscriptionModule.SearchSubscriptions(subscriptionSearchcriteria); return(new StaticPagedList <Subscription>(searchResult.Subscriptions.Select(x => x.ToSubscription(workContext.AllCurrencies, workContext.CurrentLanguage)), pageNumber, pageSize, searchResult.TotalCount.Value)); }); return(retVal); }; return(new MutablePagedList <Subscription>(subscriptionGetter, 1, SubscriptionSearchCriteria.DefaultPageSize)); }
public virtual subscriptionDto.SubscriptionSearchCriteria ToSearchCriteriaDto(SubscriptionSearchCriteria criteria) { var result = new subscriptionDto.SubscriptionSearchCriteria(); result.InjectFrom(criteria); result.Skip = criteria.Start; result.Take = criteria.PageSize; result.Sort = criteria.Sort; return(result); }
public virtual subscriptionDto.SubscriptionSearchCriteria ToSearchCriteriaDto(SubscriptionSearchCriteria criteria) { var result = new subscriptionDto.SubscriptionSearchCriteria(); result.CustomerId = criteria.CustomerId; result.Sort = criteria.Sort; result.Number = criteria.Number; result.Skip = criteria.Start; result.Take = criteria.PageSize; result.Sort = criteria.Sort; return(result); }
public static subscriptionDto.SubscriptionSearchCriteria ToSearchCriteriaDto(this SubscriptionSearchCriteria criteria) { var result = new subscriptionDto.SubscriptionSearchCriteria { CustomerId = criteria.CustomerId, Sort = criteria.Sort, Number = criteria.Number, Skip = criteria.Start, Take = criteria.PageSize }; result.Sort = criteria.Sort; return(result); }
public static subscriptionDto.SubscriptionSearchCriteria ToSearchCriteriaDto(this SubscriptionSearchCriteria criteria) { var result = new subscriptionDto.SubscriptionSearchCriteria { CustomerId = criteria.CustomerId, Sort = criteria.Sort, Number = criteria.Number, Skip = criteria.Start, Take = criteria.PageSize, ResponseGroup = ((int)criteria.ResponseGroup).ToString(), ModifiedSinceDate = criteria.ModifiedSinceDate }; result.Sort = criteria.Sort; return(result); }
private async Task <Subscription> GetSubscriptionByNumberAsync(string number) { var criteria = new subscriptionDto.SubscriptionSearchCriteria { Number = number, ResponseGroup = SubscriptionResponseGroup.Full.ToString() }; var retVal = (await _subscriptionApi.SubscriptionModule.SearchAsync(criteria)) .Subscriptions .Select(x => x.ToSubscription(WorkContext.AllCurrencies, WorkContext.CurrentLanguage)) .FirstOrDefault(); if (retVal == null || retVal.CustomerId != WorkContext.CurrentCustomer.Id) { throw new System.Web.HttpException(404, "Subscription with number " + number + " not found (or not belongs to current user)."); } return(retVal); }