private List <Task <CriminalFileAppearancesResponse> > CriminalAppearancesTasks(DateTime?proceeding, List <string> fileIds) { var targetDateInPast = DateTime.Now > proceeding; var lookForPastAppearances = targetDateInPast ? HistoryYN.Y : HistoryYN.N; var lookForFutureAppearances = targetDateInPast ? FutureYN.N : FutureYN.Y; var appearanceTasks = new List <Task <CriminalFileAppearancesResponse> >(); foreach (var fileId in fileIds) { async Task <CriminalFileAppearancesResponse> Appearances() => await _filesClient.FilesCriminalAppearancesAsync( _requestAgencyIdentifierId, _requestPartId, _applicationCode, lookForFutureAppearances, lookForPastAppearances, fileId); appearanceTasks.Add(_cache.GetOrAddAsync($"CriminalAppearances-{fileId}-InPast-{targetDateInPast}-{_requestAgencyIdentifierId}", Appearances)); } return(appearanceTasks); }
private async Task <CriminalFileAppearances> PopulateDetailsAppearancesAsync(string fileId, FutureYN?future, HistoryYN?history) { var criminalFileIdAppearances = await _filesClient.FilesCriminalAppearancesAsync(_requestAgencyIdentifierId, _requestPartId, _applicationCode, future, history, fileId); var criminalAppearances = _mapper.Map <CriminalFileAppearances>(criminalFileIdAppearances); foreach (var appearance in criminalAppearances.ApprDetail) { appearance.AppearanceReasonDsc = await _lookupService.GetCriminalAppearanceReasonsDescription(appearance.AppearanceReasonCd); appearance.AppearanceResultDsc = await _lookupService.GetCriminalAppearanceResultsDescription(appearance.AppearanceResultCd); appearance.AppearanceStatusDsc = await _lookupService.GetCriminalAppearanceStatusDescription(appearance.AppearanceStatusCd.ToString()); appearance.CourtLocationId = await _locationService.GetLocationAgencyIdentifier(appearance.CourtAgencyId); appearance.CourtLocation = await _locationService.GetLocationName(appearance.CourtAgencyId); } return(criminalAppearances); }