Exemple #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);
            }
        }
Exemple #2
0
        private void HandleEvent(WithdrawExecuted @event)
        {
            var result = Account.Withdraw(@event.Amount);

            Sender.Tell(new Result <Withdraw>(result));
        }