public Transaction CreateAccountPayment(string userId, Guid account, decimal amount, string destinationName, string destinationIBAN, string details)
        {
            var         sendingCustomer = customerService.GetCustomerFromUserId(userId);
            var         sendingAccount  = sendingCustomer.GetAccount(account);
            Transaction transaction     = null;

            using (var transactionScope = persistenceContext.BeginTransaction())
            {
                var receiverCustomer = customerRepository.GetCustomerThatOwnsIban(destinationIBAN);
                if (receiverCustomer != null)
                {
                    var destAccount = receiverCustomer.GetBankAccountByIBAN(destinationIBAN);
                    if (!destAccount.Currency.Equals(sendingAccount.Currency))
                    {
                        //throw new WrongCurrencyException(sendingAccount.Currency, destAccount.Currency);
                    }
                }
                transaction = sendingCustomer.MakePayment(account, amount, destinationName, destinationIBAN, details);

                customerRepository.Update(sendingCustomer);

                if (receiverCustomer != null)
                {
                    receiverCustomer.NotifyTransaction(transaction, sendingCustomer);
                    customerRepository.Update(receiverCustomer);
                }
                persistenceContext.SaveChanges();
            }

            return(transaction);
        }
Beispiel #2
0
        public IEnumerable <BankAccount> GetCustomerBankAccounts(string userId)
        {
            var customer = customerService.GetCustomerFromUserId(userId);

            return(customer.BankAccounts
                   .AsEnumerable());
        }