public async Task RefreshLevyAccountDetails(int pageNumber, CancellationToken cancellationToken = default(CancellationToken)) { logger.LogInfo("Now Trying to Refresh All Accounts Balance Details"); cancellationToken.ThrowIfCancellationRequested(); try { var pagedAccountsRecords = await accountApiClient.GetPageOfAccounts(pageNumber, batchSize).ConfigureAwait(false); var pagedLevyAccountModels = MapToLevyAccountModel(pagedAccountsRecords); var storedEmployers = await levyFundingSourceRepository.GetCurrentEmployerStatus(pagedLevyAccountModels.Select(x => x.AccountId).ToList(), cancellationToken); await BatchUpdateLevyAccounts(pagedLevyAccountModels, cancellationToken).ConfigureAwait(false); await PublishEmployerEvents(pagedLevyAccountModels, storedEmployers).ConfigureAwait(false); logger.LogInfo($"Successfully retrieved Account Balance Details for Page {pageNumber} of Levy Accounts"); } catch (Exception e) { logger.LogError($"Error while retrieving Account Balance Details for Page {pageNumber} of Levy Accounts", e); } }
public async Task <IEnumerable <Core.Models.Account> > FindAllDetails(int pagesize, int pageNumber) { var results = new List <Core.Models.Account>(); try { var accountPageModel = await _accountApiClient.GetPageOfAccounts(pageNumber, pagesize); if (accountPageModel?.Data?.Count > 0) { var accountsDetail = await GetAccountSearchDetails(accountPageModel.Data); results.AddRange(accountsDetail); } } catch (HttpRequestException e) { _logger.Warn($"The Account API Http request threw an exception while fetching Page {pageNumber} - Exception :\r\n{e}"); } catch (Exception e) { _logger.Error(e, $"A general exception has been thrown while requesting employer account details"); } return(results); }
public async Task RefreshLevyAccountDetails(CancellationToken cancellationToken = default(CancellationToken)) { logger.LogInfo("Now Trying to Refresh All Accounts Balance Details"); var page = 1; await retryPolicy.ExecuteAsync(GetTotalPageSize).ConfigureAwait(false); while (page <= totalPageSize) { cancellationToken.ThrowIfCancellationRequested(); try { var pagedAccountsRecords = await accountApiClient.GetPageOfAccounts(page, batchSize).ConfigureAwait(false); var pagedLevyAccountModels = MapToLevyAccountModel(pagedAccountsRecords); await BatchUpdateLevyAccounts(pagedLevyAccountModels, cancellationToken).ConfigureAwait(false); await PublishNotLevyPayerEmployerEvents(pagedLevyAccountModels).ConfigureAwait(false); logger.LogInfo($"Successfully retrieved Account Balance Details for Page {page} of Levy Accounts"); } catch (Exception e) { logger.LogError($"Error while retrieving Account Balance Details for Page {page} of Levy Accounts", e); } page++; } }
private async Task <List <LevyAccountModel> > GetPageOfLevyAccounts(int pageNumber, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); try { var pagedAccountsRecords = await accountApiClient.GetPageOfAccounts(pageNumber, accountApiBatchSize).ConfigureAwait(false); return(MapToLevyAccountModel(pagedAccountsRecords)); } catch (Exception e) { logger.LogError($"Error while retrieving Account Balance Details for Page {pageNumber} of Levy Accounts", e); return(new List <LevyAccountModel>()); } }
private async Task <Status> GetAccountsApiStatus() { try { var tsk = await _accountApiClient.GetPageOfAccounts(); return(Status.Green); } catch { return(Status.Red); } }
public async Task <PagedApiResponseViewModel <AccountWithBalanceViewModel> > GetPageOfAccounts(int pageNumber = 1, int pageSize = 1000, DateTime?toDate = null) { return(await _inner.GetPageOfAccounts(pageNumber, pageSize, toDate)); }