Exemplo n.º 1
0
        public async Task HandleAsync(StockToWalletAddedEvent message)
        {
            var orderProcessManager = await _processManagerRepository.FindAsync(message.OrderId);

            orderProcessManager.When(message);

            await _processManagerRepository.Save(orderProcessManager);
        }
Exemplo n.º 2
0
        private void Apply(StockToWalletAddedEvent @event)
        {
            var existingStock = StockList.SingleOrDefault(s => s.Code == @event.Code);

            if (existingStock != null)
            {
                existingStock.Quantity += @event.Quantity;
            }
            else
            {
                StockList.Add(new Stock(@event.CompanyId, @event.Name, @event.Code, @event.Unit, @event.Quantity));
            }
        }
Exemplo n.º 3
0
        public void When(StockToWalletAddedEvent message)
        {
            switch (State)
            {
            case BuyOrderProcessManagerState.CompanyCharged:
                State = BuyOrderProcessManagerState.OrderCompleted;
                ProcessCommand(new FinishBuyOrderCommand(AggregateId));
                break;

            default:
                throw new StocqresException("Invalid state for this message");
            }
        }