예제 #1
0
        public int CreateAccount(string firstName, string lastName, string contact, string title, decimal amount, string notes)
        {
            var ret = 0;


            if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(title))
            {
                throw new ApplicationException("Account title or customer first name could not be empty");
            }

            var customer = new Domain.Customer {
                FirstName = firstName, LastName = lastName, ContactInfo = contact, CustomerId = _context.CustomerId(), IsActive = true
            };
            var account = new Domain.Account {
                AccountName = title, AccountNo = _context.AccountId(), Balance = 0.0M, IsActive = true
            };

            customer.Accounts.Add(account);

            _context.SaveChanges();
            ret = account.AccountNo;
            _log.Info($"Account {title} for {firstName} {lastName} has been created successfully");

            ExternalTransfer(account.AccountNo, amount, "Initial Deposit");


            return(ret);
        }