diff --git a/src/Sfa.Tl.ResultsAndCertification.Application/Mappers/ExtractIndustryPlacementMapper.cs b/src/Sfa.Tl.ResultsAndCertification.Application/Mappers/ExtractIndustryPlacementMapper.cs index 0f34b42c6..e017be005 100644 --- a/src/Sfa.Tl.ResultsAndCertification.Application/Mappers/ExtractIndustryPlacementMapper.cs +++ b/src/Sfa.Tl.ResultsAndCertification.Application/Mappers/ExtractIndustryPlacementMapper.cs @@ -2,7 +2,7 @@ using Newtonsoft.Json; using Sfa.Tl.ResultsAndCertification.Domain.Models; using Sfa.Tl.ResultsAndCertification.Models.ExtractIndustryPlacement; -using Sfa.Tl.ResultsAndCertification.Models.OverallResults; +using System.Linq; namespace Sfa.Tl.ResultsAndCertification.Application.Mappers { @@ -10,14 +10,14 @@ public class ExtractIndustryPlacementMapper : Profile { public ExtractIndustryPlacementMapper() { - CreateMap() - .ForMember(d => d.Uln, opts => opts.MapFrom(s => s.TqRegistrationPathway.TqRegistrationProfile.UniqueLearnerNumber)) - .ForMember(d => d.LastName, opts => opts.MapFrom(s => s.TqRegistrationPathway.TqRegistrationProfile.Lastname)) - .ForMember(d => d.FirstName, opts => opts.MapFrom(s => s.TqRegistrationPathway.TqRegistrationProfile.Firstname)) - .ForMember(d => d.UKPRN, opts => opts.MapFrom(s => s.TqRegistrationPathway.TqProvider.TlProvider.UkPrn)) - .ForMember(d => d.ProviderName, opts => opts.MapFrom(s => s.TqRegistrationPathway.TqProvider.TlProvider.Name)) - .ForMember(d => d.IndustryPlacementStatus, opts => opts.MapFrom(s => s.Status)) - .ForMember(d => d.PendingWithdrawnFlag, opts => opts.MapFrom(s => s.TqRegistrationPathway.IsPendingWithdrawal.ToString())); + CreateMap() + .ForMember(d => d.Uln, opts => opts.MapFrom(s => s.TqRegistrationProfile.UniqueLearnerNumber)) + .ForMember(d => d.LastName, opts => opts.MapFrom(s => s.TqRegistrationProfile.Lastname)) + .ForMember(d => d.FirstName, opts => opts.MapFrom(s => s.TqRegistrationProfile.Firstname)) + .ForMember(d => d.UKPRN, opts => opts.MapFrom(s => s.TqProvider.TlProvider.UkPrn)) + .ForMember(d => d.ProviderName, opts => opts.MapFrom(s => s.TqProvider.TlProvider.Name.Replace(","," "))) + .ForMember(d => d.IndustryPlacementStatus, opts => opts.MapFrom(s => s.IndustryPlacements.Any() ? s.IndustryPlacements.First().Status.ToString() : "Null")) + .ForMember(d => d.PendingWithdrawnFlag, opts => opts.MapFrom(s => s.IsPendingWithdrawal.ToString())); } } } \ No newline at end of file diff --git a/src/Sfa.Tl.ResultsAndCertification.Application/Services/IndustryPlacementService.cs b/src/Sfa.Tl.ResultsAndCertification.Application/Services/IndustryPlacementService.cs index 48d832863..89980d794 100644 --- a/src/Sfa.Tl.ResultsAndCertification.Application/Services/IndustryPlacementService.cs +++ b/src/Sfa.Tl.ResultsAndCertification.Application/Services/IndustryPlacementService.cs @@ -376,21 +376,18 @@ public async Task ProcessIndustryPlacementExtractionsAsync() throw new ApplicationException($"Current Academic years are not found. Method: {nameof(ProcessIndustryPlacementExtractionsAsync)}"); } - // 1. Get data - var industryPlacements = await _industryPlacementRepository.GetManyAsync() - .Include(x => x.TqRegistrationPathway) - .ThenInclude(x => x.TqRegistrationProfile) - .Include(x => x.TqRegistrationPathway) - .ThenInclude(x => x.TqProvider) - .ThenInclude(x => x.TlProvider) - .Include(x => x.TqRegistrationPathway) - .ThenInclude(x => x.TqProvider) - .ThenInclude(x => x.TqAwardingOrganisation) + var industryPlacements = await _tqRegistrationPathwayRepository.GetManyAsync() + .Include(x => x.IndustryPlacements) + .Include(x => x.TqRegistrationProfile) + .Include(x => x.TqProvider) + .ThenInclude(x => x.TlProvider) + .Include(x => x.TqProvider) + .ThenInclude(x => x.TqAwardingOrganisation) .ThenInclude(x => x.TlAwardingOrganisaton) - .Where(x => x.TqRegistrationPathway.Status == RegistrationPathwayStatus.Active && - x.TqRegistrationPathway.EndDate == null && - x.TqRegistrationPathway.AcademicYear == currentAcademicYears.FirstOrDefault().Year - 1) - .ToListAsync(); + .Where(w => w.Status == RegistrationPathwayStatus.Active && + w.EndDate == null && + w.AcademicYear == currentAcademicYears.FirstOrDefault().Year - 1) + .ToListAsync(); var industryPlacementResults = _mapper.Map>(industryPlacements); @@ -410,7 +407,6 @@ public async Task ProcessIndustryPlacementExtractionsAsync() throw new ApplicationException(message); } - string result = System.Text.Encoding.UTF8.GetString(byteData); var blobUniqueReference = Guid.NewGuid(); // 3. Write response to blob diff --git a/src/Sfa.Tl.ResultsAndCertification.Functions/CertificatePrinting.cs b/src/Sfa.Tl.ResultsAndCertification.Functions/CertificatePrinting.cs index 382f06f5a..b64df9bdd 100644 --- a/src/Sfa.Tl.ResultsAndCertification.Functions/CertificatePrinting.cs +++ b/src/Sfa.Tl.ResultsAndCertification.Functions/CertificatePrinting.cs @@ -26,7 +26,7 @@ public CertificatePrinting(ResultsAndCertificationConfiguration configuration, I _configuration = configuration; _commonService = commonService; _certificatePrintingService = certificatePrintingService; - } + } [FunctionName(Constants.GenerateCertificatePrintingBatches)] public async Task GenerateCertificatePrintingBatchesAsync([TimerTrigger("%CertificatePrintingBatchesCreateTrigger%")] TimerInfo timer, ExecutionContext context, ILogger logger) @@ -79,7 +79,7 @@ public async Task GenerateCertificatePrintingBatchesAsync([TimerTrigger("%Certif } } } - + [FunctionName(Constants.FetchCertificatePrintingBatchSummary)] public async Task FetchCertificatePrintingBatchSummaryAsync([TimerTrigger("%CertificatePrintingBatchSummaryTrigger%")] TimerInfo timer, ExecutionContext context, ILogger logger) { @@ -125,7 +125,7 @@ public async Task FetchCertificatePrintingBatchSummaryAsync([TimerTrigger("%Cert await _commonService.SendFunctionJobFailedNotification(context.FunctionName, errorMessage); } } - + [FunctionName(Constants.SubmitCertificatePrintingRequest)] public async Task SubmitCertificatePrintingRequestAsync([TimerTrigger("%CertificatePrintingRequestTrigger%")] TimerInfo timer, ExecutionContext context, ILogger logger) { @@ -171,7 +171,7 @@ public async Task SubmitCertificatePrintingRequestAsync([TimerTrigger("%Certific await _commonService.SendFunctionJobFailedNotification(context.FunctionName, errorMessage); } } - + [FunctionName(Constants.FetchCertificatePrintingTrackBatch)] public async Task FetchCertificatePrintingTrackBatchAsync([TimerTrigger("%CertificatePrintingTrackBatchTrigger%")] TimerInfo timer, ExecutionContext context, ILogger logger) { diff --git a/src/Sfa.Tl.ResultsAndCertification.Functions/LearnerGender.cs b/src/Sfa.Tl.ResultsAndCertification.Functions/LearnerGender.cs index 6415cfc35..78d538d9d 100644 --- a/src/Sfa.Tl.ResultsAndCertification.Functions/LearnerGender.cs +++ b/src/Sfa.Tl.ResultsAndCertification.Functions/LearnerGender.cs @@ -21,7 +21,7 @@ public LearnerGender(ICommonService commonService, ILrsLearnerService learnerSer _commonService = commonService; _learnerService = learnerService; } - + [FunctionName(Constants.FetchLearnerGender)] public async Task FetchLearnerGenderAsync([TimerTrigger("%LearnerGenderTrigger%")]TimerInfo timer, ExecutionContext context, ILogger logger) { diff --git a/src/Sfa.Tl.ResultsAndCertification.Functions/LearnerVerificationAndLearningEvents.cs b/src/Sfa.Tl.ResultsAndCertification.Functions/LearnerVerificationAndLearningEvents.cs index 05d663e94..65cfb608c 100644 --- a/src/Sfa.Tl.ResultsAndCertification.Functions/LearnerVerificationAndLearningEvents.cs +++ b/src/Sfa.Tl.ResultsAndCertification.Functions/LearnerVerificationAndLearningEvents.cs @@ -21,7 +21,7 @@ public LearnerVerificationAndLearningEvents(ICommonService commonService, ILrsPe _commonService = commonService; _personalLearningRecordService = personalLearningRecordService; } - + [FunctionName(Constants.VerifyLearnerAndFetchLearningEvents)] public async Task VerifyLearnerAndFetchLearningEventsAsync([TimerTrigger("%LearnerVerificationAndLearningEventsTrigger%")]TimerInfo timer, ExecutionContext context, ILogger logger) { diff --git a/src/Sfa.Tl.ResultsAndCertification.Functions/OverallResultCalculation.cs b/src/Sfa.Tl.ResultsAndCertification.Functions/OverallResultCalculation.cs index a1edba557..5741386ff 100644 --- a/src/Sfa.Tl.ResultsAndCertification.Functions/OverallResultCalculation.cs +++ b/src/Sfa.Tl.ResultsAndCertification.Functions/OverallResultCalculation.cs @@ -27,7 +27,7 @@ public OverallResultCalculation(ResultsAndCertificationConfiguration configurati _overallResultCalculationService = overallResultCalculationService; _commonService = commonService; } - + [FunctionName(Constants.OverallResultCalculation)] public async Task OverallResultCalculationAsync([TimerTrigger("%OverallResultCalculationTrigger%")] TimerInfo timer, ExecutionContext context, ILogger logger) { diff --git a/src/Sfa.Tl.ResultsAndCertification.Functions/UcasDataTransfer.cs b/src/Sfa.Tl.ResultsAndCertification.Functions/UcasDataTransfer.cs index 720eabf2f..8528314ec 100644 --- a/src/Sfa.Tl.ResultsAndCertification.Functions/UcasDataTransfer.cs +++ b/src/Sfa.Tl.ResultsAndCertification.Functions/UcasDataTransfer.cs @@ -22,7 +22,7 @@ public UcasDataTransfer(IUcasDataTransferService ucasDataTransferService, ICommo _ucasDataTransferService = ucasDataTransferService; _commonService = commonService; } - + [FunctionName(Constants.UcasTransferEntries)] public async Task UcasTransferEntriesAsync([TimerTrigger("%UcasTransferEntriesTrigger%")] TimerInfo timer, ExecutionContext context, ILogger logger) { @@ -68,7 +68,7 @@ public async Task UcasTransferEntriesAsync([TimerTrigger("%UcasTransferEntriesTr } } } - + [FunctionName(Constants.UcasTransferResults)] public async Task UcasTransferResultsAsync([TimerTrigger("%UcasTransferResultsTrigger%")] TimerInfo timer, ExecutionContext context, ILogger logger) { @@ -114,7 +114,7 @@ public async Task UcasTransferResultsAsync([TimerTrigger("%UcasTransferResultsTr } } } - + [FunctionName(Constants.UcasTransferAmendments)] public async Task UcasTransferAmendmentsAsync([TimerTrigger("%UcasTransferAmendmentsTrigger%")] TimerInfo timer, ExecutionContext context, ILogger logger) {