From e843b07e0171d631820dc37ead75f3361df681c6 Mon Sep 17 00:00:00 2001 From: plockwood Date: Tue, 29 Oct 2024 16:05:34 +0000 Subject: [PATCH] fix for project enrichment - projects without a trust reference --- .../Commands/Legacy/Project/EnrichProjectCommand.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Dfe.Academies.Academisation.Service/Commands/Legacy/Project/EnrichProjectCommand.cs b/Dfe.Academies.Academisation.Service/Commands/Legacy/Project/EnrichProjectCommand.cs index d4c1d87a9..52f62c9a5 100644 --- a/Dfe.Academies.Academisation.Service/Commands/Legacy/Project/EnrichProjectCommand.cs +++ b/Dfe.Academies.Academisation.Service/Commands/Legacy/Project/EnrichProjectCommand.cs @@ -29,25 +29,19 @@ public async Task Execute() foreach (var project in incompleteProjects) { EstablishmentDto? school = await establishmentRepository.GetEstablishment(project.Details.Urn); + // trust could be null here for sposored conversion that do not have a preferred trust TrustDto trust = await establishmentRepository.GetTrustByReferenceNumber(project.Details.TrustReferenceNumber); - - + if (school == null) { logger.LogWarning("No schools found for project - {project}, urn - {urn}", project.Id, project.Details.Urn); continue; } - - if (trust == null) - { - logger.LogWarning("No trusts found for project - {project}, urn - {urn}", project.Id, project.Details.Urn); - continue; - } var projectChanges = new ConversionProjectServiceModel(project.Id, project.Details.Urn) { - TrustUkprn = Int32.Parse(trust.Ukprn), + TrustUkprn = int.TryParse(trust?.Ukprn, out var ukprn) ? ukprn : null, LocalAuthority = school.LocalAuthorityName, Region = school.Gor.Name, SchoolPhase = school.PhaseOfEducation.Name,