예제 #1
0
        /// <inheritdoc/>
        public void OpenAccount(string name, AccountType accountType, IAccountBonus bonusType, IAccountNumberCreateService createService)
        {
            BankAccount newAccount = null;

            int id = createService.CreateId();

            while (this.Accounts.Any(a => a.AccountNumber == id))
            {
                id = createService.CreateId();
            }

            switch (accountType)
            {
            case AccountType.Base:
                newAccount = new BaseBankAccount(id, name, bonusType);
                break;

            case AccountType.Silver:
                newAccount = new SilverBankAccount(id, name, bonusType);
                break;

            case AccountType.Gold:
                newAccount = new GoldBankAccount(id, name, bonusType);
                break;
            }

            this.Accounts.Add(newAccount);

            this.SaveAccountsToStorage();
        }
 /// <summary>
 /// Method for adding new account into Account repository
 /// </summary>
 /// <param name="client">Owner of account</param>
 /// <param name="startAmount">Value of start amount</param>
 public void Create(Client client, decimal startAmount)
 {
     if (startAmount >= 0m && startAmount < 1000m)
     {
         var account = new BaseBankAccount(client, startAmount);
         bankAccounts.Add(account);
     }
     else if (startAmount >= 1000m && startAmount < 5000m)
     {
         var account = new SilverBankAccount(client, startAmount);
         bankAccounts.Add(account);
     }
     else if (startAmount >= 5000m && startAmount < 10000m)
     {
         var account = new GoldBankAccount(client, startAmount);
         bankAccounts.Add(account);
     }
     else if (startAmount >= 10000m)
     {
         var account = new PlatinumBankAccount(client, startAmount);
         bankAccounts.Add(account);
     }
 }