Пример #1
0
        public virtual orderDto.CustomerOrderSearchCriteria ToSearchCriteriaDto(OrderSearchCriteria criteria)
        {
            var result = new orderDto.CustomerOrderSearchCriteria();

            result.InjectFrom(criteria);

            result.Skip = criteria.Start;
            result.Take = criteria.PageSize;
            result.Sort = criteria.Sort;

            return(result);
        }
        public static orderDto.CustomerOrderSearchCriteria ToSearchCriteriaDto(this OrderSearchCriteria criteria)
        {
            var result = new orderDto.CustomerOrderSearchCriteria
            {
                CustomerId = criteria.CustomerId,

                Skip = criteria.Start,
                Take = criteria.PageSize,
                Sort = criteria.Sort
            };

            return(result);
        }
Пример #3
0
        public static orderDto.CustomerOrderSearchCriteria ToSearchCriteriaDto(this OrderSearchCriteria criteria)
        {
            var result = new orderDto.CustomerOrderSearchCriteria
            {
                Keyword    = criteria.Keyword,
                CustomerId = criteria.CustomerId,
                StartDate  = criteria.StartDate,
                EndDate    = criteria.EndDate,
                Status     = criteria.Status,
                Statuses   = criteria.Statuses,
                StoreIds   = criteria.StoreIds,

                Skip = criteria.Start,
                Take = criteria.PageSize,
                Sort = criteria.Sort
            };

            return(result);
        }
Пример #4
0
        protected virtual IMutablePagedList <CustomerOrder> GetCustomerOrders(CustomerInfo customer)
        {
            var workContext         = _workContextFactory();
            var orderSearchcriteria = new orderDto.CustomerOrderSearchCriteria
            {
                CustomerId    = customer.Id,
                ResponseGroup = "full"
            };

            Func <int, int, IEnumerable <SortInfo>, IPagedList <CustomerOrder> > ordersGetter = (pageNumber, pageSize, sortInfos) =>
            {
                //TODO: add caching
                orderSearchcriteria.Skip = (pageNumber - 1) * pageSize;
                orderSearchcriteria.Take = pageSize;
                var cacheKey       = "GetCustomerOrders-" + orderSearchcriteria.GetHashCode();
                var ordersResponse = _cacheManager.Get(cacheKey, string.Format(_customerOrdersCacheRegionFormat, customer.Id), () => _orderApi.OrderModule.Search(orderSearchcriteria));
                return(new StaticPagedList <CustomerOrder>(ordersResponse.CustomerOrders.Select(x => x.ToCustomerOrder(workContext.AllCurrencies, workContext.CurrentLanguage)), pageNumber, pageSize,
                                                           ordersResponse.TotalCount.Value));
            };

            return(new MutablePagedList <CustomerOrder>(ordersGetter, 1, OrderSearchCriteria.DefaultPageSize));
        }