Example #1
0
        /// <summary>
        /// Returns a list of ebay transaction types matching a specified time period
        /// </summary>
        /// <param name="from">Start date and time of the requiered time period</param>
        /// <param name="until">End date and time of the requiered time period</param>
        /// <returns></returns>
        public static List <TransactionType> LoadEbayTransactions(DateTime from, DateTime until)
        {
            List <TransactionType> result = new List <TransactionType>();

            //Get all sales
            GetSellerTransactionsCall transactionCall = new GetSellerTransactionsCall(EbayController.GetApiContext());

            transactionCall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);
            transactionCall.IncludeContainingOrder = true;
            transactionCall.Site       = SiteCodeType.Germany;
            transactionCall.Pagination = new PaginationType();
            transactionCall.Pagination.EntriesPerPage = 200;

            Int32 pageNumber = 1;

            do
            {
                transactionCall.Pagination.PageNumber = pageNumber;
                TransactionTypeCollection transactionPage = transactionCall.GetSellerTransactions(from, until);

                result.AddRange(transactionPage.ToArray());

                pageNumber++;
            }while (transactionCall.HasMoreTransactions);

            //Get all orders for the loaded sales
            var           orderIds  = from current in result where current.ContainingOrder != null select current.ContainingOrder.OrderID;
            GetOrdersCall orderCall = new GetOrdersCall(EbayController.GetApiContext());

            orderCall.OrderIDList = new StringCollection(orderIds.ToArray());
            orderCall.Execute();

            //Assign orders to sales
            List <OrderType> orders = new List <OrderType>(orderCall.OrderList.ToArray());

            foreach (TransactionType current in result)
            {
                if (current.ContainingOrder != null)
                {
                    current.ContainingOrder = orders.FirstOrDefault(x => x.OrderID == current.ContainingOrder.OrderID);
                }
            }

            return(result);
        }