Exemplo n.º 1
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)}");
            }
        }
        public void OpenAccount(AccountHolder holder, BankAccountFactory factory)
        {
            ValidateOnNull(holder, nameof(holder));
            ValidateOnNull(factory, nameof(factory));

            BankAccount account = factory.Create(holder, this.IdGenerator);

            holder.AddAccount(account);
            this.Repository.Save(account);
        }