public async Task <string> GetEmployerAccountId(string userId)
        {
            if (string.IsNullOrWhiteSpace(userId))
            {
                throw new ArgumentException("User Id is required but is not provided");
            }
            try
            {
                var accounts = await _accountApiClient.GetUserAccounts(userId);

                return(accounts.First().HashedAccountId);

                // Currenly the API isn't passing through the correct details
                // of the registered date
                // We may be able to rely on the order from the api. They do
                // look like they're returned in the order they are created.
                // .OrderBy(x => x.DateRegistered)
                // .ThenBy(x => x.HashedAccountId)
                // .First().HashedAccountId;
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Failed to retrieve account information for user Id: {userId}");
                throw;
            }
        }
        public async Task <IEnumerable <EmployerIdentifier> > GetEmployerIdentifiersAsync(string userId)
        {
            var accounts = await _accountApiClient.GetUserAccounts(userId);

            return(accounts
                   .Select(acc =>
                           new EmployerIdentifier {
                AccountId = acc.HashedAccountId, EmployerName = acc.DasAccountName
            }));
        }
        public async Task <IEnumerable <string> > GetEmployerIdentifiersAsync(string userId)
        {
            try
            {
                var accounts = await _accountApiClient.GetUserAccounts(userId);

                return(accounts.Select(acc => acc.HashedAccountId));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Failed to retrieve account information for user Id: {userId}");
                throw;
            }
        }
        public async Task <ICollection <AccountDetailViewModel> > GetAccounts(string id)
        {
            try
            {
                _logger.Debug($"{nameof(IAccountApiClient)}.{nameof(_employerAccountsApiClient.GetUserAccounts)}(\"{id}\");");
                var response = await _employerAccountsApiClient.GetUserAccounts(id);

                return(response ?? new Collection <AccountDetailViewModel>());
            }
            catch (Exception ex)
            {
                _logger.Error(ex, $"Error while trying to get User Accounts for user id {id}");

                throw;
            }
        }
Beispiel #5
0
        private async Task <string> GetEmployerAccountId(string userId)
        {
            try
            {
                var accounts = await _accountApiClient.GetUserAccounts(userId);

                return(accounts
                       .OrderBy(x => x.AccountId) // AccountId is ascendingly sequential
                       .First().HashedAccountId);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Failed to retrieve account information for user Id: {userId}");
                throw;
            }
        }
Beispiel #6
0
 public async Task <ICollection <AccountDetailViewModel> > Handle(GetUserAccountsQuery request, CancellationToken cancellationToken)
 {
     return(await _accountApiClient.GetUserAccounts(request.UserId));
 }
 public async Task <ICollection <AccountDetailViewModel> > GetUserAccounts(string userId)
 {
     return(await _inner.GetUserAccounts(userId));
 }