Пример #1
0
 private User(Guid id) : base(id)
 {
     Apply <UserCreated>(e =>
     {
         Login   = e.Login;
         Id      = e.SourceId;
         Account = e.Account;
     });
     Apply <SkuPurchaseOrdered>(
         e => { PendingOrders[e.OrderId] = new PendingOrder(e.OrderId, e.SkuId, e.Quantity, e.StockId); });
     Apply <PendingOrderCanceled>(e =>
     {
         if (!PendingOrders.Remove(e.OrderId))
         {
             _logger.Warning("Could not find pending order {order} to cancel", e.OrderId);
         }
     });
     Apply <PendingOrderCompleted>(e =>
     {
         if (!PendingOrders.Remove(e.OrderId))
         {
             _logger.Warning("Could not find pending order {order} to complete",
                             e.OrderId);
         }
     });
 }
Пример #2
0
        private void HandleCompleteOrder(object parameter)
        {
            var order = (Order)parameter;

            //TODO: if the order is fully paid, we can close it, otherwise we should just mark it 'completed'
            order.OrderStateId = order.PaymentStateId == PaymentStates.Paid ? OrderStates.Closed : OrderStates.Completed;

            DataService.UpdateObject(order);
            DataService.SaveChanges();

            PendingOrders.Remove(order);
        }
Пример #3
0
        public void Handle(OrderCommited t)
        {
            var pendingOrder = PendingOrders.FirstOrDefault(o => o.OrderId == t.Order.OrderId);

            if (pendingOrder == null)
            {
                return;
            }

            PendingOrders.Remove(pendingOrder);

            Console.WriteLine($"Order Complete: {pendingOrder.OrderId}");
        }
Пример #4
0
        private void ReQueryOrders(object sender, EventArgs e)
        {
            var oldMergeOption = DataService.MergeOption;

            DataService.MergeOption = MergeOption.OverwriteChanges;
            var orders = DataService.Orders.Expand("OrderItems").Where(x => x.OrderStateId == OrderStates.Cooking).ToList();

            foreach (var order in orders.Where(order => !PendingOrders.Contains(order)))
            {
                PendingOrders.Add(order);
            }
            foreach (var pendingOrder in PendingOrders.Where(pendingOrder => !orders.Contains(pendingOrder)))
            {
                PendingOrders.Remove(pendingOrder);
            }
            DataService.MergeOption = oldMergeOption;
        }
Пример #5
0
 private void CancelPendingOrder()
 {
     data.CancelOrder(SelectedPendingOrder, ActiveDepot.ExchangeName);
     PendingOrders.Remove(SelectedPendingOrder);
 }