diff --git a/Dfe.Academies.Academisation.IDomain/TransferProjectAggregate/ITransferringAcademy.cs b/Dfe.Academies.Academisation.IDomain/TransferProjectAggregate/ITransferringAcademy.cs index 92c6baf75..1818aa9a2 100644 --- a/Dfe.Academies.Academisation.IDomain/TransferProjectAggregate/ITransferringAcademy.cs +++ b/Dfe.Academies.Academisation.IDomain/TransferProjectAggregate/ITransferringAcademy.cs @@ -20,6 +20,8 @@ public interface ITransferringAcademy string? DistanceFromAcademyToTrustHq { get; } string? DistanceFromAcademyToTrustHqDetails { get; } string? PublishedAdmissionNumber { get; } + string? Region { get; } + string? LocalAuthority { get; } void SetSchoolAdditionalData(string latestOfstedReportAdditionalInformation, string pupilNumbersAdditionalInformation, string keyStage2PerformanceAdditionalInformation, string keyStage4PerformanceAdditionalInformation, string keyStage5PerformanceAdditionalInformation); diff --git a/Dfe.Academies.Academisation.IService/Query/ITransferProjectQueryService.cs b/Dfe.Academies.Academisation.IService/Query/ITransferProjectQueryService.cs index 0505ac3bc..c4c3658a3 100644 --- a/Dfe.Academies.Academisation.IService/Query/ITransferProjectQueryService.cs +++ b/Dfe.Academies.Academisation.IService/Query/ITransferProjectQueryService.cs @@ -7,7 +7,7 @@ public interface ITransferProjectQueryService { Task GetByUrn(int Urn); Task GetById(int id); - Task?> GetTransferProjectsByIncomingTrustUkprn(string ukprn, CancellationToken cancellationToken); + Task?> GetTransferProjectsByIncomingTrustUkprn(string ukprn, CancellationToken cancellationToken); Task> GetTransferProjects(int page, int count, int? urn, string title); Task?> GetProjects(IEnumerable? states, string? title, IEnumerable? deliveryOfficers, int page, int count); diff --git a/Dfe.Academies.Academisation.Service.UnitTest/Queries/TransferProjectQueryServiceTests.cs b/Dfe.Academies.Academisation.Service.UnitTest/Queries/TransferProjectQueryServiceTests.cs index a7fad8ca3..e76d90ce4 100644 --- a/Dfe.Academies.Academisation.Service.UnitTest/Queries/TransferProjectQueryServiceTests.cs +++ b/Dfe.Academies.Academisation.Service.UnitTest/Queries/TransferProjectQueryServiceTests.cs @@ -266,6 +266,8 @@ public async Task GetProjects_ReturnsFilteredProjects() IncomingTrustName = a.IncomingTrustName, IncomingTrustUkprn = a.IncomingTrustUkprn, OutgoingAcademyUkprn = a.OutgoingAcademyUkprn, + Region = a.Region, + LocalAuthority = a.LocalAuthority }).ToList(), AssignedUser = null!, IsFormAMat = false @@ -301,14 +303,14 @@ public async Task GetTransferProjectsByIncomingTrustUkprn_ShouldReturnTranferPro ); var cancelationToken = CancellationToken.None; _mockTransferProjectRepository.Setup(repo => repo.GetTransferProjectsByIncomingTrustUkprn(trustUrn, cancelationToken)) - .ReturnsAsync([(ITransferProject?)dummyTransferProject!]); - var expectedResponse = AcademyTransferProjectResponseFactory.Create(dummyTransferProject); + .ReturnsAsync([(dummyTransferProject!)]); + var expectedResponse = _service.AcademyTransferProjectSummaryResponse([dummyTransferProject]); // Action var result = await _service.GetTransferProjectsByIncomingTrustUkprn(trustUrn, cancelationToken); // Assert - result.Should().BeEquivalentTo([expectedResponse]); + result.Should().BeEquivalentTo(expectedResponse); } [Fact] public async Task GetTransferProjectsByIncomingTrustUkprn_ShouldReturnNoTranferProject() diff --git a/Dfe.Academies.Academisation.Service/Mappers/TransferProject/AcademyTransferProjectResponseFactory.cs b/Dfe.Academies.Academisation.Service/Mappers/TransferProject/AcademyTransferProjectResponseFactory.cs index fc7b60891..a6b1545e6 100644 --- a/Dfe.Academies.Academisation.Service/Mappers/TransferProject/AcademyTransferProjectResponseFactory.cs +++ b/Dfe.Academies.Academisation.Service/Mappers/TransferProject/AcademyTransferProjectResponseFactory.cs @@ -10,9 +10,9 @@ public static AcademyTransferProjectResponse Create(ITransferProject model) { if (model == null) { - return null; + return null!; } - + var transferringAcademies = model.TransferringAcademies .Select(a => new TransferringAcademyDto { @@ -31,7 +31,9 @@ public static AcademyTransferProjectResponse Create(ITransferProject model) ViabilityIssues = a.ViabilityIssues, FinancialDeficit = a.FinancialDeficit, MPNameAndParty = a.MPNameAndParty, - PublishedAdmissionNumber = a.PublishedAdmissionNumber + PublishedAdmissionNumber = a.PublishedAdmissionNumber, + LocalAuthority = a.LocalAuthority, + Region = a.Region }) .ToList(); @@ -95,9 +97,9 @@ public static AcademyTransferProjectResponse Create(ITransferProject model) { Id = model.Id, ProjectUrn = model.Urn.ToString(), - ProjectReference = model.ProjectReference, + ProjectReference = model.ProjectReference!, OutgoingTrustUkprn = model.OutgoingTrustUkprn, - OutgoingTrustName = model.OutgoingTrustName, + OutgoingTrustName = model.OutgoingTrustName!, TransferringAcademies = transferringAcademies, Features = features, Dates = dates, diff --git a/Dfe.Academies.Academisation.Service/Queries/TransferProjectQueryService.cs b/Dfe.Academies.Academisation.Service/Queries/TransferProjectQueryService.cs index 0deb9eb7a..c5ad80c73 100644 --- a/Dfe.Academies.Academisation.Service/Queries/TransferProjectQueryService.cs +++ b/Dfe.Academies.Academisation.Service/Queries/TransferProjectQueryService.cs @@ -8,7 +8,6 @@ using Dfe.Academies.Academisation.Service.Factories; using Dfe.Academies.Academisation.Service.Mappers.TransferProject; using Dfe.Academies.Contracts.V4.Establishments; -using static System.Net.WebRequestMethods; namespace Dfe.Academies.Academisation.Service.Queries { @@ -45,12 +44,10 @@ public TransferProjectQueryService( public async Task> GetTransferProjects(int page, int count, int? urn, string title) { - IEnumerable transferProjects = FilterByUrn( - await _transferProjectRepository.GetAllTransferProjects(), urn).ToList(); + var transferProjects = FilterByUrn(await _transferProjectRepository.GetAllTransferProjects(), urn).ToList(); //the logic retrieving the trust data goes here - IEnumerable projects = - FilterByIncomingTrust(title, AcademyTransferProjectSummaryResponse(transferProjects)); + var projects = FilterByIncomingTrust(title, AcademyTransferProjectSummaryResponse(transferProjects)); // remove any projects without an outgoing trust. projects = projects @@ -231,7 +228,9 @@ public IEnumerable AcademyTransferProject FinancialDeficit = ta.FinancialDeficit, ViabilityIssues = ta.ViabilityIssues, MPNameAndParty = ta.MPNameAndParty, - PublishedAdmissionNumber = ta.PublishedAdmissionNumber + PublishedAdmissionNumber = ta.PublishedAdmissionNumber, + LocalAuthority = ta.LocalAuthority, + Region = ta.Region, }; }).ToList(), IsFormAMat = x.IsFormAMat @@ -239,14 +238,11 @@ public IEnumerable AcademyTransferProject }); } - public async Task?> GetTransferProjectsByIncomingTrustUkprn(string ukprn, CancellationToken cancellationToken) + public async Task?> GetTransferProjectsByIncomingTrustUkprn(string ukprn, CancellationToken cancellationToken) { var transferProjects = await _transferProjectRepository.GetTransferProjectsByIncomingTrustUkprn(ukprn, cancellationToken); - var transers = new List(); - foreach (var transferProject in transferProjects) { - transers.Add(AcademyTransferProjectResponseFactory.Create(transferProject!)); - } - return transers; + + return AcademyTransferProjectSummaryResponse(transferProjects); } } diff --git a/Dfe.Academies.Academisation.WebApi/Controllers/TransferProjectController.cs b/Dfe.Academies.Academisation.WebApi/Controllers/TransferProjectController.cs index 240fd4f1f..00a5ac446 100644 --- a/Dfe.Academies.Academisation.WebApi/Controllers/TransferProjectController.cs +++ b/Dfe.Academies.Academisation.WebApi/Controllers/TransferProjectController.cs @@ -355,7 +355,7 @@ public async Task>> GetOpeningDa } [HttpGet("{ukprn}/get-transfers-by-incoming-trust", Name = "GetTransfersByIncomingTrust")] - public async Task>> GetTransfersByincomingTrust(string ukprn, CancellationToken cancellationToken) + public async Task>> GetTransfersByincomingTrust(string ukprn, CancellationToken cancellationToken) { _logger.LogInformation("Getting transfer projects by incoming trust ukprn: {value}", ukprn);