Exemple #1
0
        public Account CreateAccount(string name, AccountType accountType, decimal balance = 0M)
        {
            _lastId += 1;

            switch (accountType)
            {
            case AccountType.ConsumerAccount:
                var newConsumerAccount = new ConsumerAccount(name)
                {
                    Balance = balance
                };
                _fileRepository.AddRow(newConsumerAccount);
                LoggerService.Write($"[NEW_ACCOUNT] NEW CONSUMER ACCOUNT, ID = {newConsumerAccount.Id}");
                return(newConsumerAccount);

            case AccountType.CheckingAccount:
                var newCheckingAccount = new CheckingAccount(name)
                {
                    Balance = balance
                };
                _fileRepository.AddRow(newCheckingAccount);
                LoggerService.Write($"[NEW_ACCOUNT] NEW CHECKING ACCOUNT, ID = {newCheckingAccount.Id}");
                return(newCheckingAccount);

            case AccountType.SavingsAccount:
                var newSavingsAccount = new SavingsAccount(name)
                {
                    Balance = balance
                };
                _fileRepository.AddRow(newSavingsAccount);
                LoggerService.Write($"[NEW_ACCOUNT] NEW SAVINGS ACCOUNT, ID = {newSavingsAccount.Id}");
                return(newSavingsAccount);

            default:
                throw new Exception("MissingAccountType");
                break;
            }
        }