Пример #1
0
        public void AddAccount(Holder holder, string type)
        {
            var id          = _accountIdService.GenerateAccountId();
            var accountType = AccountTypeMapper.GetAccountType(type);
            var account     = new Account(id, 0, holder, accountType, new Bonus());

            _repository.Add(account.ToDTOAccount());
            holder.Accounts.Add(id);
        }
Пример #2
0
        private string GetUniqueAccoutId(string email, string ownerSecondName, int spinCount = 4000)
        {
            string id;
            int    i           = 0;
            var    temp        = _accountRepository.GetAccounts();
            var    dalAccounts = temp as DalAccount[] ?? temp.ToArray();

            do
            {
                id = _accountIdService.GenerateAccountId(email, ownerSecondName);
                if (++i >= spinCount)
                {
                    throw new AccountServiceException("Failed to get the unique account ID.");
                }
            }while (dalAccounts.Any(dalAccount => string.Compare(dalAccount.Id, id, StringComparison.Ordinal) == 0));

            return(id);
        }