Exemplo n.º 1
0
            // handle commands

            public static (Event Event, AccountState NewState) Debit
                (this AccountState @this, MakeTransfer transfer)
            {
                var evt      = transfer.ToEvent();
                var newState = @this.Apply(evt);

                return(evt, newState);
            }
Exemplo n.º 2
0
            public static AccountState Apply(this AccountState @this, Event evt)
            => new Pattern <AccountState>
            {
                (DepositedCash e) => @this.Credit(e.Amount),
                (DebitedTransfer e) => @this.Debit(e.DebitedAmount),
                (FrozeAccount e) => @this.WithStatus(AccountStatus.Frozen),
            }

            .Match(evt);