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

            try
            {
                orderProcessManager.When(message);
            }
            catch (StocqresException e)
            {
                orderProcessManager.When(new BuyOrderCancelledEvent(e.Message));
            }

            await _processManagerRepository.Save(orderProcessManager);
        }
Exemplo n.º 2
0
        public void When(WalletChargedEvent message)
        {
            switch (State)
            {
            case BuyOrderProcessManagerState.OrderPlaced:
                State = BuyOrderProcessManagerState.InvestorWalletCharged;
                ChargedWalletAmount = message.Amount;
                ProcessCommand(new ChargeCompanyCommand(CompanyId, AggregateId, StockQuantity));
                break;

            case BuyOrderProcessManagerState.InvestorWalletCharged:
                break;

            default:
                throw new StocqresException("Invalid state for this message");
            }
        }
Exemplo n.º 3
0
 private void Apply(WalletChargedEvent @event)
 {
     Amount -= @event.Amount;
 }