private async Task <IEnumerable <IList <Notification> > > GetGroupedResultsAsNotificationAsync(IEnumerable <IGrouping <string, string> > groupedIds, PerformContext context, string requestId) { var resultList = new List <IList <Notification> >(); foreach (var group in groupedIds) { var legacyIds = group.ToList(); _logger.LogInformation(context, requestId, $"Fetching data for legacy notifications {string.Join(", ", legacyIds)}"); var legacyNotifications = _migrationRepository.GetNotificationsById(legacyIds); var sitesOfDisease = _migrationRepository.GetNotificationSites(legacyIds); var manualTestResults = _migrationRepository.GetManualTestResults(legacyIds); var socialContextVenues = _migrationRepository.GetSocialContextVenues(legacyIds); var socialContextAddresses = _migrationRepository.GetSocialContextAddresses(legacyIds); var transferEvents = _migrationRepository.GetTransferEvents(legacyIds); var outcomeEvents = _migrationRepository.GetOutcomeEvents(legacyIds); var mbovisAnimalExposure = _migrationRepository.GetMigrationMBovisAnimalExposure(legacyIds); var mbovisExposureToKnownCase = _migrationRepository.GetMigrationMBovisExposureToKnownCase(legacyIds); var mbovisOccupationExposures = _migrationRepository.GetMigrationMBovisOccupationExposures(legacyIds); var mbovisUnpasteurisedMilkConsumption = _migrationRepository.GetMigrationMBovisUnpasteurisedMilkConsumption(legacyIds); var notificationsForGroup = await CombineDataForGroup( legacyIds, (await legacyNotifications).ToList(), (await sitesOfDisease).ToList(), (await manualTestResults).ToList(), (await socialContextVenues).ToList(), (await socialContextAddresses).ToList(), (await transferEvents).ToList(), (await outcomeEvents).ToList(), (await mbovisAnimalExposure).ToList(), (await mbovisExposureToKnownCase).ToList(), (await mbovisOccupationExposures).ToList(), (await mbovisUnpasteurisedMilkConsumption).ToList() ); resultList.Add(notificationsForGroup); } return(resultList); }