Beispiel #1
0
        protected override bool ReceiveCommand(object message)
        {
            switch (message)
            {
            case CheckBalance checkBalance:
                Sender.Tell(new BalanceStatus(Account.Balance));
                return(true);

            case Deposit deposit:
                var depositExecutedEvent = new DepositExecuted(deposit.Amount);
                Persist(depositExecutedEvent, HandleEvent);
                return(true);

            case Withdraw withdraw:
                var withdrawExecutedEvent = new WithdrawExecuted(withdraw.Amount);
                Persist(withdrawExecutedEvent, HandleEvent);
                return(true);

            default:
                return(false);
            }
        }
Beispiel #2
0
 private void HandleEvent(DepositExecuted @event)
 {
     Account.Deposit(@event.Amount);
     Sender.Tell(new Result <Deposit>(Status.Success));
 }