public static IQueryable <TModel> Order <TModel>(this IQueryable <TModel> query,
                                                         IOrderOptions orderOptions,
                                                         IReadOnlyDictionary <string, Expression <Func <TModel, object> > > orderingMap)
        {
            Argument.IsNotNull(nameof(orderingMap), orderingMap);

            if (!string.IsNullOrWhiteSpace(orderOptions.OrderColumn) &&
                orderingMap.TryGetValue(orderOptions.OrderColumn, out var orderFunction))
            {
                return(orderOptions.OrderAscending ? query.OrderBy(orderFunction)
                      : query.OrderByDescending(orderFunction));
            }

            return(query);
        }
Exemplo n.º 2
0
        public ExternalOrderResult GetOrders(IOrderOptions orderOptions)
        {
            ExternalOrderResult result = new ExternalOrderResult();

            List<ExternalOrder> orders = new List<ExternalOrder>();

            eBayOrderOptions ebayOptions = (eBayOrderOptions)orderOptions;

            //eBayOrderOptions options = ebayOptions.GetOrderOptions();

            GetOrdersCall getOrders = new GetOrdersCall(eBayContext);

            getOrders.OrderStatus = OrderStatusCodeType.Completed;

            getOrders.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);

            getOrders.CreateTimeFrom = ebayOptions.FromDate.Value;

            getOrders.CreateTimeTo = ebayOptions.ToDate.Value;

            PaginationType pagination = new PaginationType()
            {
                EntriesPerPage = 10,
                PageNumber = 0,
            };

            getOrders.Pagination = pagination;

            getOrders.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);

            bool hasMoreOrders = false;

            do
            {
                pagination.PageNumber += 1;

                getOrders.Pagination = pagination;

                getOrders.Execute();

                if (getOrders.ApiResponse.Ack != AckCodeType.Failure)
                {

                    if (getOrders.ApiResponse.OrderArray.Count != 0)
                    {

                        Debug.Print("Total  orders: {0}", getOrders.ApiResponse.PaginationResult.TotalNumberOfEntries);

                        Debug.Print("Page No.{0},  orders:{1}", getOrders.PageNumber, getOrders.ApiResponse.OrderArray.Count);

                        List<OrderType> orderList = getOrders.OrderList.ToArray().ToList();
                        orderList = getOrders.OrderList.ToArray().ToList();

                        List<ExternalOrder> pageOrders = GetOrderDetails(orderList);

                        orders.AddRange(pageOrders);

                        hasMoreOrders = getOrders.HasMoreOrders;
                    }

                }
                else
                {

                    throw new Exception("eBay Orders can not be retrieved");

                }

            } while (hasMoreOrders);

            result.Success = true;

            result.Orders = orders;

            return result;
        }