/// <summary>
        /// Opens a new account for <paramref name="holder"/> with <paramref name="startBalance"/>.
        /// </summary>
        /// <param name="holder">person's full name</param>
        /// <param name="startBalance">first deposit amount</param>
        /// <returns>IBAN of a new account</returns>
        /// <exception cref="ArgumentException">Start balance is lesser than minimal.</exception>
        public string OpenAccount(string holder, decimal startBalance)
        {
            if (string.IsNullOrWhiteSpace(holder))
            {
                throw new ArgumentException("No significant characters are given.", "holder");
            }

            if (startBalance < MINDEPOSIT)
            {
                throw new ArgumentException($"Cannot create a bank account with balance lesser than {MINDEPOSIT}");
            }

            BankAccount account;

            if (startBalance <= 1000)
            {
                account = new StandardAccount(IBANGenerator.GenerateIBAN(), holder, startBalance, bonusPoints: 0);
            }
            else if (startBalance <= 10000)
            {
                account = new GoldAccount(IBANGenerator.GenerateIBAN(), holder, startBalance, bonusPoints: 5);
            }
            else
            {
                account = new PlatinumAccount(IBANGenerator.GenerateIBAN(), holder, startBalance, bonusPoints: 10);
            }

            Storage.AddAccount(BankAccountMapper.ToDTO(account));

            return(account.IBAN);
        }
예제 #2
0
        public static Account.Account Create(AccountHolder accountHolder, string id, TypeOfBankScore typeOfBankScore, Status status = Status.Open)
        {
            Account.Account account = null;

            switch (typeOfBankScore)
            {
            case TypeOfBankScore.Base:
                accountHolder.AddAccount(id);
                account        = new BaseAccount(id, accountHolder);
                account.Status = status;
                return(account);

            case TypeOfBankScore.Silver:
                accountHolder.AddAccount(id);
                account        = new SilverAccount(id, accountHolder);
                account.Status = status;
                return(account);

            case TypeOfBankScore.Gold:
                accountHolder.AddAccount(id);
                account        = new GoldAccount(id, accountHolder);
                account.Status = status;
                return(account);

            case TypeOfBankScore.Platinum:
                accountHolder.AddAccount(id);
                account         = new PlatinumAccount(id, accountHolder);
                account.Status  = status;
                account.Balance = 20;
                return(account);

            default:
                throw new ArgumentException($"Invalid {nameof(typeOfBankScore)}");
            }
        }
예제 #3
0
        /// <summary>
        /// Opens a new account for <paramref name="owner"/> with <paramref name="startBalance"/>.
        /// </summary>
        /// <param name="owner">person's full name</param>
        /// <param name="startBalance">first deposit amount</param>
        /// <returns>IBAN of a new account</returns>
        /// <exception cref="ArgumentException">Start balance is lesser than minimal.</exception>
        public string OpenAccount(AccountOwner owner, decimal startBalance)
        {
            if (owner == null)
            {
                throw new ArgumentNullException(nameof(owner));
            }

            BankAccount account;

            if (startBalance < 1000)
            {
                account = new StandardAccount(ibanGenerator.GenerateIBAN(), owner, startBalance, bonusPoints: 0);
            }
            else if (startBalance < 10000)
            {
                account = new GoldAccount(ibanGenerator.GenerateIBAN(), owner, startBalance, bonusPoints: 5);
            }
            else
            {
                account = new PlatinumAccount(ibanGenerator.GenerateIBAN(), owner, startBalance, bonusPoints: 10);
            }

            accountsRepo.Accounts.Create(account.ToDTO());
            accountsRepo.Save();

            return(account.IBAN);
        }
예제 #4
0
        public static Account Create(AccountType type, Person owner, string number, decimal sum, bool isClosed)
        {
            Account newAccount = null;

            switch (type)
            {
            case AccountType.Base:
                newAccount = new BaseAccount(owner, number, sum, isClosed);
                break;

            case AccountType.Gold:
                newAccount = new GoldAccount(owner, number, sum, isClosed);
                break;

            case AccountType.Platinum:
                newAccount = new PlatinumAccount(owner, number, sum, isClosed);
                break;
            }

            return(newAccount);
        }