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 Validation <(Event Event, AccountState NewState)> Freeze
            (this AccountState @this, FreezeAccount cmd)
        {
            if (@this.Status == AccountStatus.Frozen)
            {
                return(Errors.AccountNotActive);
            }

            FrozeAccount evt      = cmd.ToEvent();
            AccountState newState = @this.Apply(evt);

            return(evt as Event, newState);
        }
Exemplo n.º 3
0
        // handle commands

        public static Validation <(Event Event, AccountState NewState)> Debit
            (this AccountState @this, MakeTransfer cmd)
        {
            if (@this.Status != AccountStatus.Active)
            {
                return(Errors.AccountNotActive);
            }

            if (@this.Balance - cmd.Amount < @this.AllowedOverdraft)
            {
                return(Errors.InsufficientBalance);
            }

            DebitedTransfer evt      = cmd.ToEvent();
            AccountState    newState = @this.Apply(evt);

            return(evt as Event, newState);
        }