Exemplo n.º 1
0
        /// <summary>
        /// When user change the BankID of transaction it is necessary to delete this transaction from BankAccount that not belong to anymore And add transaction to the list of transaction of new BankAccount.
        ///
        /// <para>This function fires up an event that BankAccount Subscribed, and the BankAccount fires up an event that User subscribe.
        /// If User private delegate will say that BankAccount with given ID exists it will move transaction to choosen BankAccount list. </para>
        ///
        /// <para>Throws DomainException with error code= "bank_acc_nfound" if BankAccount with given ID won't be found</para>
        /// </summary>
        /// <param name="bankAccountId"> id of new bank account</param>
        public virtual void setBankAccount(int bankAccountId)
        {
            if (bankAccountId.isEmpty())
            {
                throw new DomainException(DomainErrorCodes.EmptyId);
            }

            if (BankAccountId.isEmpty())
            {
                BankAccountId = bankAccountId;
            }
            else if (BankAccountId != bankAccountId)
            {
                if (BankAccountIDChanedEvent.Invoke(this, bankAccountId))
                {
                    BankAccountId = bankAccountId;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Throws Exception When Trying to add emptyID, when bankAccountId was not found or when trying to set Source and Destination Bank Id to the same value
        /// </summary>
        /// <param name="bankAccountId"></param>
        public void setSourceBankAccount(int bankAccountId)
        {
            if (bankAccountId.isEmpty())
            {
                throw new DomainException(DomainErrorCodes.EmptyId);
            }

            if (bankAccountId == DestinationBankAccountId)
            {
                throw new DomainException(DomainErrorCodes.SourceAndDestiantionIDCantBeSame);
            }

            if (BankAccountId.isEmpty())
            {
                BankAccountId = bankAccountId;
            }
            else if (BankAccountId != bankAccountId)
            {
                if (SourceBankAccountIDChanedEvent.Invoke(this, bankAccountId))
                {
                    BankAccountId = bankAccountId;
                }
            }
        }