Esempio n. 1
0
        /// <inheritdoc />
        public string CreateAccount(
            AccountType type,
            IAccountNumberGenerator numberGenerator,
            string ownerFirstName,
            string ownerLastName,
            string ownerEmail,
            decimal balance = 0m,
            int bonus       = 0)
        {
            if (ReferenceEquals(numberGenerator, null))
            {
                throw new ArgumentNullException(nameof(numberGenerator));
            }

            try
            {
                string accountNumber = numberGenerator.CreateNumber(_repository.GetAllAccounts().ToBllAccounts());
                var    account       = CreateAccountOfSpecifiedType(type, accountNumber, ownerFirstName, ownerLastName, ownerEmail, balance, bonus);

                _repository.AddAccount(account.ToDtoAccount());

                return(accountNumber);
            }
            catch (Exception ex)
            {
                throw new BankAccountServiceException("Some error occuried while creating new account.", ex);
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> Get()
        {
            var accounts = await _accountRepository.GetAllAccounts();

            var result = AutoMapper.Mapper.Map <IEnumerable <BankAccountDto> >(accounts);

            return(Ok(result));
        }