public async Task <Dictionary <string, Item> > GetItems()
        {
            Dictionary <string, Order> orders = null;

            try
            {
                orders = await orderProcessor.GetOrders();
            }
            catch
            {
            }

            var items = await invhandler.FetchItems();

            foreach (var itmKey in items.Keys)
            {
                int sum = orders?.Values.Where(o => o.Item.ID == int.Parse(itmKey)).Sum(o => o.Quantity) ?? 0;
                items[itmKey].Quantity -= sum;
            }
            return(items);
        }
예제 #2
0
 /// <summary>
 /// Get a list of all open orders.
 /// </summary>
 /// <returns>List of open orders.</returns>
 public List <Order> GetOpenOrders()
 {
     return(_orderProcessor.GetOrders(x => x.Status.IsOpen()).ToList());
 }
예제 #3
0
 /// <summary>
 /// Gets all orders matching the specified filter. Specifying null will return an enumerable
 /// of all orders.
 /// </summary>
 /// <param name="filter">Delegate used to filter the orders</param>
 /// <returns>All orders this order provider currently holds by the specified filter</returns>
 public IEnumerable <Order> GetOrders(Func <Order, bool> filter)
 {
     return(_orderProcessor.GetOrders(filter));
 }
예제 #4
0
 /// <summary>
 /// Get a list of all open orders.
 /// </summary>
 /// <returns>List of open orders.</returns>
 public List <Order> GetOpenOrders()
 {
     return(_orderProcessor.GetOrders(x => x.Status == OrderStatus.Submitted || x.Status == OrderStatus.New).ToList());
 }
예제 #5
0
 /// <summary>
 /// Gets all orders matching the specified filter. Specifying null will return an enumerable
 /// of all orders.
 /// </summary>
 /// <param name="filter">Delegate used to filter the orders</param>
 /// <returns>All orders this order provider currently holds by the specified filter</returns>
 public IEnumerable <Order> GetOrders(Func <Order, bool> filter = null)
 {
     return(_orderProcessor.GetOrders(filter ?? (x => true)));
 }