Exemplo n.º 1
0
        public Transaction Transfer(Account accountToDebit, Account accountToCredit, double valueToTransfer)
        {
            ValidateTransfer(accountToDebit, accountToCredit, valueToTransfer);

            using (var transScope = new TransactionScope())
            {
                accountToDebit.Debit(valueToTransfer);
                accountToCredit.Credit(valueToTransfer);

                var transaction = new Transaction(accountToDebit, accountToCredit, valueToTransfer);

                AccountRepository.Save(accountToDebit);
                AccountRepository.Save(accountToCredit);
                BankStatementRepository.RegisterTransaction(transaction);
                transScope.Complete();

                return(transaction);
            }
        }
Exemplo n.º 2
0
        public Transaction Transfer(Account accountToDebit, Account accountToCredit, double valueToTransfer)
        {
            ValidateTransfer(accountToDebit, accountToCredit, valueToTransfer);

            using (var transScope = new TransactionScope())
            {
                accountToDebit.Debit(valueToTransfer);
                accountToCredit.Credit(valueToTransfer);

                var transaction = new Transaction(accountToDebit, accountToCredit, valueToTransfer);

                AccountRepository.Save(accountToDebit);
                AccountRepository.Save(accountToCredit);
                BankStatementRepository.RegisterTransaction(transaction);
                transScope.Complete();

                return transaction;
            }
        }