예제 #1
0
            // handle commands

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

                return(evt, newState);
            }
예제 #2
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);
        }
예제 #3
0
 public Transaction(DebitedTransfer e)
 {
    this.DebitedAmount = e.DebitedAmount;
    Description = $"Transfer to {e.Bic}/{e.Iban}; Ref: {e.Reference}";
    Date = e.Timestamp.Date;
 }