Пример #1
0
        /// <summary>
        /// Smart constructor.
        /// </summary>
        public static Validation <BookTransfer> Of(
            Func <DateTime> now,
            decimal amountToTransfer,
            string beneficiaryOfTransfer,
            string bicCode,
            DateTime dateOfTransfer,
            string debitedAccountId,
            string internationalBankAccountNumber,
            string referenceOfTransfer,
            DateTime timestampOfTransfer)
        {
            var date        = TransferDate.Of(dateOfTransfer, now);
            var amount      = Amount.Of(amountToTransfer);
            var beneficiary = Beneficiary.Of(beneficiaryOfTransfer);
            var bic         = Bic.Of(bicCode);
            var accountId   = AccountId.Of(debitedAccountId);
            var iban        = Iban.Of(internationalBankAccountNumber);
            var reference   = Reference.Of(referenceOfTransfer);
            var timestamp   = Timestamp.Of(timestampOfTransfer, now);

            return(IsValid(amount, date, beneficiary, bic, accountId, iban, reference, timestamp)
                ? Valid(new BookTransfer(
                            amount.GetObject(), date.GetObject(), beneficiary.GetObject(), bic.GetObject(), accountId.GetObject(), iban.GetObject(), reference.GetObject(), timestamp.GetObject()))
                : Invalid(GetErrors(amount, date, beneficiary, bic, accountId, iban, reference, timestamp)));
        }
Пример #2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 private BookTransfer(Amount amount, TransferDate date, Beneficiary beneficiary, Bic bic, AccountId accountId, Iban iban, Reference reference, Timestamp timestamp)
 {
     DateOfTransfer        = date;
     AmountToTransfer      = amount;
     BeneficiaryOfTransfer = beneficiary;
     BicCode          = bic;
     DebitedAccountId = accountId;
     InternationalBankAccountNumber = iban;
     ReferenceOfTransfer            = reference;
     TimestampOfTransfer            = timestamp;
 }