// 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); }
// 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); }
public Transaction(DebitedTransfer e) { this.DebitedAmount = e.DebitedAmount; Description = $"Transfer to {e.Bic}/{e.Iban}; Ref: {e.Reference}"; Date = e.Timestamp.Date; }