コード例 #1
0
        public string OpenAccount(AccountType accountType, IAccountNumberCreateService creator, string ownerName, string ownerEmail, decimal balance = 0m, int benefitPoints = 0)
        {
            string accountNumber = creator.Create(GetNumberOfAccounts());
            var    account       = CreateAccountType(accountNumber, accountType, ownerName, ownerEmail, balance, benefitPoints);

            repository.Create(account.ToDalAccount());
            unitOfWork.Commit();

            return(accountNumber);
        }
コード例 #2
0
        /// <summary>
        /// Creates new account.
        /// </summary>
        /// <param name="name">Name of account's owner.</param>
        /// <param name="accountType">Type of account.</param>
        /// <param name="creator">Service for creating number of account.</param>
        public void OpenAccount(string name, string email, AccountType accountType, IAccountNumberCreateService creator)
        {
            Account account = null;

            switch (accountType)
            {
            case AccountType.Base:
                account = new BaseAccount(creator.Create(accountNum++), name, email);
                break;

            case AccountType.Gold:
                account = new GoldAccount(creator.Create(accountNum++), name, email);
                break;

            case AccountType.Platinum:
                account = new PlatinumAccount(creator.Create(accountNum++), name, email);
                break;
            }
            repository.Create(account.ToAccountDto());
        }