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); } }
private void HandleEvent(DepositExecuted @event) { Account.Deposit(@event.Amount); Sender.Tell(new Result <Deposit>(Status.Success)); }