/// <summary>
        /// Create new account in repository
        /// </summary>
        /// <param name="name"></param>
        /// <param name="type">AccountType to choose what type of account we use</param>
        /// <param name="creator">Creates number for account</param>
        public void OpenAccount(string name, AccountType type, IAccountNumberCreateService creator)
        {
            Account acc;

            switch (type)
            {
            case AccountType.Base:
                acc = new BaseAccount(name, creator.GetNextNumber(name));
                break;

            case AccountType.Silver:
                acc = new SilverAccount(name, creator.GetNextNumber(name));
                break;

            case AccountType.Gold:     // Isn't implemented.
                acc = new SilverAccount(name, creator.GetNextNumber(name));
                break;

            default:
                acc = new BaseAccount(name, creator.GetNextNumber(name));
                break;
            }

            repos.AddToAccountList(acc);
            accountsCount++;
        }
예제 #2
0
        public void OpenAccount(string ownerName, string accountType, IAccountNumberCreateService numberCreator)
        {
            if (string.IsNullOrEmpty(ownerName))
            {
                throw new ArgumentException("Argument is null or empty", nameof(ownerName));
            }

            if (numberCreator is null)
            {
                throw new ArgumentNullException(nameof(numberCreator));
            }

            var account = accountFactory.GetInstance(accountType);

            account.AccountNumber = numberCreator.GetNextNumber();
            account.Owner         = new AccountOwner()
            {
                FirstName = ownerName
            };
            account.Status = AccountStatus.Active;

            repository.Create(account.ToAccountDto());
        }