diff --git a/CypressTests/cypress/integration/academytransfers/academyTransferE2E.js b/CypressTests/cypress/integration/academytransfers/academyTransferE2E.js deleted file mode 100644 index e27b2e67..00000000 --- a/CypressTests/cypress/integration/academytransfers/academyTransferE2E.js +++ /dev/null @@ -1,87 +0,0 @@ -describe("E2E Academy Transfers", () => { - let apiKey = Cypress.env('apiKey'); - let url = Cypress.env('url'); - var savedURN; - var savedOutgoingTrustUkprn; - var originalAcademyPerformanceAdditionalInformation; - - it('GET All Academy Transfer Projects', () => { - cy.request({ - method : 'GET', - failOnStatusCode: false, - url: url+"academyTransferProject", - headers: { - ApiKey: apiKey, - "Content-type" : "application/json" - } - }) - .then((response) =>{ - expect(response.status).to.eq(200); - savedURN = response.body.results[0].projectUrn; - cy.log("1st Project URN = "+savedURN); - savedOutgoingTrustUkprn = response.body.results[0].outgoingTrustUkprn; - cy.log("1st Project outgoingTrustUkprn = "+savedOutgoingTrustUkprn); - }) - - }); - - it('Find and update a Project and verify the changes', () => { - cy.request({ - method : 'GET', - failOnStatusCode: false, - url: url+"academyTransferProject/"+savedURN, - headers: { - ApiKey: apiKey, - "Content-type" : "application/json" - } - }) - .then((response) =>{ - expect(response.status).to.eq(200); - savedOutgoingTrustUkprn = response.body.outgoingTrustUkprn; - cy.log("savedOutgoingTrustUkprn = "+savedOutgoingTrustUkprn); - expect("Project URN = "+response.body.projectUrn).to.eq("Project URN = "+savedURN); - originalAcademyPerformanceAdditionalInformation = response.body.academyPerformanceAdditionalInformation; - cy.log("originalAcademyPerformanceAdditionalInformation = "+originalAcademyPerformanceAdditionalInformation); - }) - - // *****academyPerformanceAdditionalInformation does not exist and requires necessary information to complete tests***** - - // cy.request({ - // method : 'PATCH', - // failOnStatusCode: false, - // body:{ - // "outgoingTrustUkprn": `${savedOutgoingTrustUkprn}`, - // "academyPerformanceAdditionalInformation": "Offstead Report - UPDATE TEST" - // }, - // url: url+"academyTransferProject/"+savedURN, - // headers: { - // ApiKey: apiKey, - // "Content-type" : "application/json" - // } - // }) - // .then((response) =>{ - // expect(response.status).to.eq(200); - // expect(response.body.academyPerformanceAdditionalInformation) - // .to.eq("Offstead Report - UPDATE TEST"); - // }) - - // cy.request({ - // method : 'PATCH', - // failOnStatusCode: false, - // body:{ - // "outgoingTrustUkprn": `${savedOutgoingTrustUkprn}`, - // "academyPerformanceAdditionalInformation": `${originalAcademyPerformanceAdditionalInformation}` - // }, - // url: url+"academyTransferProject/"+savedURN, - // headers: { - // ApiKey: apiKey, - // "Content-type" : "application/json" - // } - // }) - // .then((response) =>{ - // expect(response.status).to.eq(200); - // expect(response.body.academyPerformanceAdditionalInformation) - // .to.eq(originalAcademyPerformanceAdditionalInformation); - // }) - }); -}); \ No newline at end of file diff --git a/TramsDataApi.Test/Controllers/AcademyTransferProjectsControllerTests.cs b/TramsDataApi.Test/Controllers/AcademyTransferProjectsControllerTests.cs deleted file mode 100644 index 3d05aaf6..00000000 --- a/TramsDataApi.Test/Controllers/AcademyTransferProjectsControllerTests.cs +++ /dev/null @@ -1,258 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using Moq; -using TramsDataApi.Controllers; -using TramsDataApi.RequestModels; -using TramsDataApi.RequestModels.AcademyTransferProject; -using TramsDataApi.ResponseModels.AcademyTransferProject; -using TramsDataApi.UseCases; -using Xunit; - -namespace TramsDataApi.Test.Controllers -{ - public class AcademyTransferProjectsControllerTests - { - private readonly Mock> mockLogger = new Mock>(); - - [Fact] - public void CreateAcademyTransferProject_Returns201WhenSuccessfullyCreatesAnAcademyTransferProject() - { - var createAcademyTransferProject = new Mock(); - var createAcademyTransferRequest = Builder - .CreateNew().With(atp => atp.OutgoingTrustUkprn = "12345678").Build(); - - var academyTransferProjectResponse = Builder - .CreateNew().Build(); - - createAcademyTransferProject.Setup(a => a.Execute(createAcademyTransferRequest)) - .Returns(academyTransferProjectResponse); - - var controller = new AcademyTransferProjectController( - createAcademyTransferProject.Object, - new Mock().Object, - new Mock().Object, - new Mock().Object, - new Mock().Object, - mockLogger.Object - ); - var result = controller.Create(createAcademyTransferRequest); - - result.Result.Should().BeEquivalentTo(new CreatedAtActionResult("Create", null, null,academyTransferProjectResponse)); - } - - [Fact] - public void CreateAcademyTransferProject_Returns401WhenGivenIncompleteRequest() - { - var createAcademyTransferProject = new Mock(); - var createAcademyTransferRequest = Builder - .CreateNew().With(atp => atp.OutgoingTrustUkprn = null).Build(); - - createAcademyTransferProject.Setup(a => a.Execute(createAcademyTransferRequest)) - .Throws(new Exception("Shouldn't be called.")); - - var controller = new AcademyTransferProjectController( - createAcademyTransferProject.Object, - new Mock().Object, - new Mock().Object, - new Mock().Object, - new Mock().Object, - mockLogger.Object - ); - var result = controller.Create(createAcademyTransferRequest); - - result.Result.Should().BeEquivalentTo(new BadRequestResult()); - } - - [Fact] - public void UpdateAcademyTransferProject_Returns404WhenProjectNotFound() - { - var urn = 10001001; - var updateAcademyTransferProject = new Mock(); - var getAcademyTransferProject = new Mock(); - - var updateAcademyTransferRequest = Builder.CreateNew().Build(); - - getAcademyTransferProject.Setup(useCase => useCase.Execute(urn)).Returns(() => null); - - var controller = new AcademyTransferProjectController( - new Mock().Object, - new Mock().Object, - getAcademyTransferProject.Object, - updateAcademyTransferProject.Object, - new Mock().Object, - mockLogger.Object - ); - var result = controller.Update(urn, updateAcademyTransferRequest); - - result.Result.Should().BeEquivalentTo(new NotFoundResult()); - } - - [Fact] - public void UpdateAcademyTransferProject_UpdatesTheProject_WhenItIsFound() - { - var urn = 10000323; - var updateAcademyTransferProject = new Mock(); - var getAcademyTransferProject = new Mock(); - - var updateAcademyTransferRequest = Builder - .CreateNew().With(uat => uat.OutgoingTrustUkprn = "12345671").Build(); - var updateAcademyTransferResponse = Builder.CreateNew().Build(); - - getAcademyTransferProject.Setup(useCase => useCase.Execute(urn)) - .Returns(Builder.CreateNew().Build); - - updateAcademyTransferProject.Setup(useCase => useCase.Execute(urn, updateAcademyTransferRequest)) - .Returns(updateAcademyTransferResponse); - - var controller = new AcademyTransferProjectController( - new Mock().Object, - new Mock().Object, - getAcademyTransferProject.Object, - updateAcademyTransferProject.Object, - new Mock().Object, - mockLogger.Object - ); - var result = controller.Update(urn, updateAcademyTransferRequest); - - result.Result.Should().BeEquivalentTo(new OkObjectResult(updateAcademyTransferResponse)); - } - - [Fact] - public void UpdateAcademyTransferProject_ReturnsBadRequest_WhenInvalidRequestIsGiven() - { - var urn = 10000323; - var updateAcademyTransferProject = new Mock(); - var getAcademyTransferProject = new Mock(); - - var updateAcademyTransferRequest = Builder - .CreateNew().With(uat => uat.OutgoingTrustUkprn = null).Build(); - - getAcademyTransferProject.Setup(useCase => useCase.Execute(urn)) - .Returns(Builder.CreateNew().Build); - - var controller = new AcademyTransferProjectController( - new Mock().Object, - new Mock().Object, - getAcademyTransferProject.Object, - updateAcademyTransferProject.Object, - new Mock().Object, - mockLogger.Object - ); - var result = controller.Update(urn, updateAcademyTransferRequest); - - result.Result.Should().BeEquivalentTo(new BadRequestResult()); - } - - [Fact] - public void GetAcademyTransferProject_ReturnsNotFound_WhenAcademyTransferProjectDoesNotExist() - { - var urn = 10021231; - var getAcademyTransferProject = new Mock(); - - getAcademyTransferProject - .Setup(get => get.Execute(urn)) - .Returns(() => null); - - var controller = new AcademyTransferProjectController( - new Mock().Object, - new Mock().Object, - getAcademyTransferProject.Object, - new Mock().Object, - new Mock().Object, - mockLogger.Object - ); - - var result = controller.GetByUrn(urn); - - result.Result.Should().BeEquivalentTo(new NotFoundResult()); - } - - [Fact] - public void GetAcademyTransferProject_ReturnsOkResult_WhenAcademyTransferProjectExists() - { - var urn = 10546231; - var getAcademyTransferProject = new Mock(); - var academyTransferProjectResponse = Builder.CreateNew().Build(); - - getAcademyTransferProject - .Setup(get => get.Execute(urn)) - .Returns(academyTransferProjectResponse); - - var controller = new AcademyTransferProjectController( - new Mock().Object, - new Mock().Object, - getAcademyTransferProject.Object, - new Mock().Object, - new Mock().Object, - mockLogger.Object - ); - - var result = controller.GetByUrn(urn); - - result.Result.Should().BeEquivalentTo(new OkObjectResult(academyTransferProjectResponse)); - } - - [Fact] - public void IndexAcademyTransferProject_ReturnsEmptyList_WhenThereAreNoAcademyTransferProjects() - { - var indexAcademyTransferProject = new Mock(); - - indexAcademyTransferProject - .Setup(get => get.Execute(1)) - .Returns(() => - Tuple.Create, int>( - new List(), 0)); - - var controller = new AcademyTransferProjectController( - new Mock().Object, - new Mock().Object, - new Mock().Object, - new Mock().Object, - indexAcademyTransferProject.Object, - mockLogger.Object - ); - - var result = controller.Index(); - - var expectedPagedResult = - new PagedResult(Enumerable - .Empty()); - - result.Result.Should().BeEquivalentTo(new OkObjectResult(expectedPagedResult)); - } - - [Fact] - public void IndexAcademyTransferProject_ReturnsListOfAcademyTransferProjects_WhenThereAreAcademyTransferProjects() - { - var expectedIndexAcademyTransferProjectResponse = Builder.CreateListOfSize(5).Build(); - - var indexAcademyTransferProject = new Mock(); - - indexAcademyTransferProject - .Setup(get => get.Execute(1)) - .Returns(() => Tuple.Create(expectedIndexAcademyTransferProjectResponse, - expectedIndexAcademyTransferProjectResponse.Count)); - - var controller = new AcademyTransferProjectController( - new Mock().Object, - new Mock().Object, - new Mock().Object, - new Mock().Object, - indexAcademyTransferProject.Object, - mockLogger.Object - ); - - var result = controller.Index(); - - var expectedPagedResult = new PagedResult( - expectedIndexAcademyTransferProjectResponse, expectedIndexAcademyTransferProjectResponse.Count); - - result.Result.Should().BeEquivalentTo(new OkObjectResult(expectedPagedResult)); - } - } -} \ No newline at end of file diff --git a/TramsDataApi.Test/Factories/AcademyTransferProjectFactoryTests.cs b/TramsDataApi.Test/Factories/AcademyTransferProjectFactoryTests.cs deleted file mode 100644 index 866e3bd8..00000000 --- a/TramsDataApi.Test/Factories/AcademyTransferProjectFactoryTests.cs +++ /dev/null @@ -1,632 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using TramsDataApi.DatabaseModels; -using TramsDataApi.Factories; -using TramsDataApi.RequestModels; -using TramsDataApi.RequestModels.AcademyTransferProject; -using TramsDataApi.Services; -using Xunit; - -namespace TramsDataApi.Test.Factories -{ - public class AcademyTransferProjectFactoryTests - { - [Fact] - public void ReturnsAnAcademyTransferProject_WhenGivenAnInitialAcademyTransferProjectRequest() - { - var randomGenerator = new RandomGenerator(); - DateTime expectedCreateDateTime = DateTime.Now; - DateTimeSource.UtcNow = () => expectedCreateDateTime; - var createRequest = Builder.CreateNew() - .With(c => c.OutgoingTrustUkprn = randomGenerator.NextString(8, 8)) - .With(c => c.Status = null) - .With(c => c.State = null) - .With(c => c.GeneralInformation = null) - .With(c => c.Benefits = null) - .With(c => c.Dates = null) - .With(c => c.Rationale = null) - .With(c => c.Features = null) - .With(c => c.TransferringAcademies = - (List) Builder - .CreateListOfSize(5) - .All() - .With(t => t.OutgoingAcademyUkprn = randomGenerator.NextString(8, 8)) - .With(t => t.IncomingTrustUkprn = null) - .With(t => t.PupilNumbersAdditionalInformation = null) - .With(t => t.LatestOfstedReportAdditionalInformation = null) - .With(t => t.KeyStage2PerformanceAdditionalInformation = null) - .With(t => t.KeyStage4PerformanceAdditionalInformation = null) - .With(t => t.KeyStage5PerformanceAdditionalInformation = null).Build()) - .Build(); - - var expected = new AcademyTransferProjects - { - ProjectReference = createRequest.ProjectReference, - OutgoingTrustUkprn = createRequest.OutgoingTrustUkprn, - WhoInitiatedTheTransfer = null, - RddOrEsfaIntervention = null, - RddOrEsfaInterventionDetail = null, - TypeOfTransfer = null, - OtherTransferTypeDescription = null, - TransferFirstDiscussed = null, - TargetDateForTransfer = null, - HtbDate = null, - ProjectRationale = null, - TrustSponsorRationale = null, - State = null, - Status = null, - Author = null, - Recommendation = null, - HighProfileShouldBeConsidered = null, - HighProfileFurtherSpecification = null, - ComplexLandAndBuildingShouldBeConsidered = null, - ComplexLandAndBuildingFurtherSpecification = null, - FinanceAndDebtShouldBeConsidered = null, - FinanceAndDebtFurtherSpecification = null, - OtherBenefitValue = null, - AcademyTransferProjectIntendedTransferBenefits = null, - FeatureSectionIsCompleted = null, - BenefitsSectionIsCompleted = null, - LegalRequirementsSectionIsCompleted = null, - CreatedOn = DateTimeSource.UtcNow(), - RationaleSectionIsCompleted = null, - TransferringAcademies = createRequest.TransferringAcademies - .Select(t => new TransferringAcademies - { - OutgoingAcademyUkprn = t.OutgoingAcademyUkprn, - IncomingTrustUkprn = null, - LatestOfstedReportAdditionalInformation = null, - PupilNumbersAdditionalInformation = null, - KeyStage2PerformanceAdditionalInformation = null, - KeyStage4PerformanceAdditionalInformation = null, - KeyStage5PerformanceAdditionalInformation = null - }) - .ToList() - }; - - var result = AcademyTransferProjectFactory.Create(createRequest); - - result.Should().BeEquivalentTo(expected); - } - - [Fact] - public void ReturnsAnAcademyTransferProject_WhenGivenACompleteAcademyTransferProjectRequest() - { - DateTime expectedCreateDateTime = DateTime.Now; - DateTimeSource.UtcNow = () => expectedCreateDateTime; - var randomGenerator = new RandomGenerator(); - - var benefitsRequest = Builder.CreateNew() - .With(b => b.IntendedTransferBenefits = Builder.CreateNew() - .With(i => i.SelectedBenefits = new List()).Build()) - .With(b => b.OtherFactorsToConsider = Builder.CreateNew() - .With(o => o.ComplexLandAndBuilding = Builder.CreateNew().Build()) - .With(o => o.FinanceAndDebt = Builder.CreateNew().Build()) - .With(o => o.HighProfile = Builder.CreateNew().Build()) - .With(o => o.OtherRisks = Builder.CreateNew().Build()) - .Build() - ) - .Build(); - - var datesRequest = Builder.CreateNew() - .With(d => d.TransferFirstDiscussed = - randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)) - .With(d => d.TargetDateForTransfer = - randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)) - .With(d => d.HtbDate = randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)) - .With(d => d.HasTransferFirstDiscussedDate = true) - .With(d => d.HasHtbDate = true) - .With(d => d.HasTargetDateForTransfer = true) - .Build(); - - var createRequest = Builder.CreateNew() - .With(c => c.OutgoingTrustUkprn = randomGenerator.NextString(8, 8)) - .With(c => c.Benefits = benefitsRequest) - .With(c => c.Dates = datesRequest) - .With(c => c.Rationale = Builder.CreateNew().Build()) - .With(c => c.GeneralInformation = - Builder.CreateNew().Build()) - .With(c => c.Features = Builder.CreateNew().Build()) - .With(c => c.TransferringAcademies = - (List) Builder - .CreateListOfSize(5).Build()) - .With(d => d.CreatedOn = expectedCreateDateTime) - .Build(); - - var expected = new AcademyTransferProjects - { - ProjectReference = createRequest.ProjectReference, - OutgoingTrustUkprn = createRequest.OutgoingTrustUkprn, - WhoInitiatedTheTransfer = createRequest.Features.WhoInitiatedTheTransfer, - RddOrEsfaIntervention = createRequest.Features.RddOrEsfaIntervention, - RddOrEsfaInterventionDetail = createRequest.Features.RddOrEsfaInterventionDetail, - TypeOfTransfer = createRequest.Features.TypeOfTransfer, - OtherTransferTypeDescription = createRequest.Features.OtherTransferTypeDescription, - TransferFirstDiscussed = DateTime.ParseExact(createRequest.Dates.TransferFirstDiscussed, "dd/MM/yyyy", - CultureInfo.InvariantCulture), - TargetDateForTransfer = DateTime.ParseExact(createRequest.Dates.TargetDateForTransfer, "dd/MM/yyyy", - CultureInfo.InvariantCulture), - HtbDate = DateTime.ParseExact(createRequest.Dates.HtbDate, "dd/MM/yyyy", CultureInfo.InvariantCulture), - HasHtbDate = createRequest.Dates.HasHtbDate, - HasTransferFirstDiscussedDate = createRequest.Dates.HasTransferFirstDiscussedDate, - HasTargetDateForTransfer = createRequest.Dates.HasTargetDateForTransfer, - ProjectRationale = createRequest.Rationale.ProjectRationale, - TrustSponsorRationale = createRequest.Rationale.TrustSponsorRationale, - State = createRequest.State, - Status = createRequest.Status, - Author = createRequest.GeneralInformation.Author, - Recommendation = createRequest.GeneralInformation.Recommendation, - AnyRisks = createRequest.Benefits.AnyRisks, - HighProfileShouldBeConsidered = - createRequest.Benefits.OtherFactorsToConsider.HighProfile.ShouldBeConsidered, - HighProfileFurtherSpecification = - createRequest.Benefits.OtherFactorsToConsider.HighProfile.FurtherSpecification, - ComplexLandAndBuildingShouldBeConsidered = createRequest.Benefits.OtherFactorsToConsider - .ComplexLandAndBuilding.ShouldBeConsidered, - ComplexLandAndBuildingFurtherSpecification = createRequest.Benefits.OtherFactorsToConsider - .ComplexLandAndBuilding.FurtherSpecification, - FinanceAndDebtShouldBeConsidered = - createRequest.Benefits.OtherFactorsToConsider.FinanceAndDebt.ShouldBeConsidered, - FinanceAndDebtFurtherSpecification = - createRequest.Benefits.OtherFactorsToConsider.FinanceAndDebt.FurtherSpecification, - OtherRisksShouldBeConsidered = - createRequest.Benefits.OtherFactorsToConsider.OtherRisks.ShouldBeConsidered, - OtherRisksFurtherSpecification = - createRequest.Benefits.OtherFactorsToConsider.OtherRisks.FurtherSpecification, - OtherBenefitValue = createRequest.Benefits.IntendedTransferBenefits.OtherBenefitValue, - EqualitiesImpactAssessmentConsidered = createRequest.Benefits.EqualitiesImpactAssessmentConsidered, - FeatureSectionIsCompleted = createRequest.Features?.IsCompleted, - BenefitsSectionIsCompleted = createRequest.Benefits?.IsCompleted, - LegalRequirementsSectionIsCompleted = createRequest.LegalRequirements?.IsCompleted, - RationaleSectionIsCompleted = createRequest.Rationale?.IsCompleted, - CreatedOn = createRequest.CreatedOn, - AcademyTransferProjectIntendedTransferBenefits = createRequest.Benefits.IntendedTransferBenefits - .SelectedBenefits - .Select(b => new AcademyTransferProjectIntendedTransferBenefits {SelectedBenefit = b}).ToList(), - TransferringAcademies = createRequest.TransferringAcademies - .Select(t => new TransferringAcademies - { - OutgoingAcademyUkprn = t.OutgoingAcademyUkprn, - IncomingTrustUkprn = t.IncomingTrustUkprn, - PupilNumbersAdditionalInformation = t.PupilNumbersAdditionalInformation, - LatestOfstedReportAdditionalInformation = t.LatestOfstedReportAdditionalInformation, - KeyStage2PerformanceAdditionalInformation = t.KeyStage2PerformanceAdditionalInformation, - KeyStage4PerformanceAdditionalInformation = t.KeyStage4PerformanceAdditionalInformation, - KeyStage5PerformanceAdditionalInformation = t.KeyStage5PerformanceAdditionalInformation - }) - .ToList() - }; - - var result = AcademyTransferProjectFactory.Create(createRequest); - - result.Should().BeEquivalentTo(expected); - } - - [Fact] - public void ReturnsOriginalAcademyTransferProject_WhenUpdating_IfAcademyTransferProjectRequestIsNull() - { - var academyTransferProject = Builder.CreateNew().Build(); - - var result = AcademyTransferProjectFactory.Update(academyTransferProject, null); - - result.Should().BeEquivalentTo(academyTransferProject); - } - - [Fact] - public void ReturnsUpdatedAcademyTransferProject_WhenUpdating_IfRequestHasUpdatedFields() - { - var academyTransferProject = Builder.CreateNew().Build(); - var updateRequest = new AcademyTransferProjectRequest - { - OutgoingTrustUkprn = "12312354", - Rationale = new AcademyTransferProjectRationaleRequest - { - ProjectRationale = "A new rationale for the project" - } - }; - - var expected = new AcademyTransferProjects - { - Id = academyTransferProject.Id, - Urn = academyTransferProject.Urn, - ProjectReference = academyTransferProject.ProjectReference, - OutgoingTrustUkprn = updateRequest.OutgoingTrustUkprn, - ProjectRationale = updateRequest.Rationale.ProjectRationale, - TransferringAcademies = academyTransferProject.TransferringAcademies, - WhoInitiatedTheTransfer = academyTransferProject.WhoInitiatedTheTransfer, - TargetDateForTransfer = academyTransferProject.TargetDateForTransfer, - RddOrEsfaIntervention = academyTransferProject.RddOrEsfaIntervention, - RddOrEsfaInterventionDetail = academyTransferProject.RddOrEsfaInterventionDetail, - TypeOfTransfer = academyTransferProject.TypeOfTransfer, - OtherTransferTypeDescription = academyTransferProject.OtherTransferTypeDescription, - TransferFirstDiscussed = academyTransferProject.TransferFirstDiscussed, - HtbDate = academyTransferProject.HtbDate, - TrustSponsorRationale = academyTransferProject.TrustSponsorRationale, - State = academyTransferProject.State, - Status = academyTransferProject.Status, - Author = academyTransferProject.Author, - Recommendation = academyTransferProject.Recommendation, - AnyRisks = academyTransferProject.AnyRisks, - HighProfileShouldBeConsidered = academyTransferProject.HighProfileShouldBeConsidered, - HighProfileFurtherSpecification = academyTransferProject.HighProfileFurtherSpecification, - ComplexLandAndBuildingShouldBeConsidered = - academyTransferProject.ComplexLandAndBuildingShouldBeConsidered, - ComplexLandAndBuildingFurtherSpecification = - academyTransferProject.ComplexLandAndBuildingFurtherSpecification, - FinanceAndDebtShouldBeConsidered = academyTransferProject.FinanceAndDebtShouldBeConsidered, - FinanceAndDebtFurtherSpecification = academyTransferProject.FinanceAndDebtFurtherSpecification, - OtherRisksShouldBeConsidered = academyTransferProject.OtherRisksShouldBeConsidered, - OtherRisksFurtherSpecification = academyTransferProject.OtherRisksFurtherSpecification, - OtherBenefitValue = academyTransferProject.OtherBenefitValue, - EqualitiesImpactAssessmentConsidered = academyTransferProject.EqualitiesImpactAssessmentConsidered, - IncomingTrustAgreement = academyTransferProject.IncomingTrustAgreement, - DiocesanConsent = academyTransferProject.DiocesanConsent, - OutgoingTrustConsent = academyTransferProject.OutgoingTrustConsent, - FeatureSectionIsCompleted = academyTransferProject.FeatureSectionIsCompleted, - BenefitsSectionIsCompleted = academyTransferProject.BenefitsSectionIsCompleted, - LegalRequirementsSectionIsCompleted = academyTransferProject.LegalRequirementsSectionIsCompleted, - RationaleSectionIsCompleted = academyTransferProject.RationaleSectionIsCompleted, - AcademyTransferProjectIntendedTransferBenefits = - academyTransferProject.AcademyTransferProjectIntendedTransferBenefits, - HasTransferFirstDiscussedDate = academyTransferProject.HasTransferFirstDiscussedDate, - HasHtbDate = academyTransferProject.HasHtbDate, - HasTargetDateForTransfer = academyTransferProject.HasTargetDateForTransfer, - AssignedUserEmailAddress = academyTransferProject.AssignedUserEmailAddress, - AssignedUserFullName = academyTransferProject.AssignedUserFullName, - AssignedUserId = academyTransferProject.AssignedUserId, - - CreatedOn = academyTransferProject.CreatedOn - }; - - var result = AcademyTransferProjectFactory.Update(academyTransferProject, updateRequest); - - result.Should().BeEquivalentTo(expected); - } - - [Fact] - public void ReturnsUpdatedAcademyTransferProject_WhenUpdating_AndUpdatesTheListOfTransferringAcademies() - { - var academyTransferProject = Builder - .CreateNew() - .With(atp => atp.TransferringAcademies = Builder.CreateListOfSize(5).Build()) - .Build(); - - var transferringAcademiesRequests = academyTransferProject.TransferringAcademies.Select(ta => - new TransferringAcademiesRequest - { - OutgoingAcademyUkprn = ta.OutgoingAcademyUkprn, - IncomingTrustUkprn = ta.IncomingTrustUkprn, - LatestOfstedReportAdditionalInformation = ta.LatestOfstedReportAdditionalInformation, - PupilNumbersAdditionalInformation = ta.PupilNumbersAdditionalInformation, - KeyStage2PerformanceAdditionalInformation = ta.KeyStage2PerformanceAdditionalInformation, - KeyStage4PerformanceAdditionalInformation = ta.KeyStage4PerformanceAdditionalInformation, - KeyStage5PerformanceAdditionalInformation = ta.KeyStage5PerformanceAdditionalInformation - - }).ToList(); - transferringAcademiesRequests.ElementAt(0).OutgoingAcademyUkprn = "12385731"; - - var updateRequest = new AcademyTransferProjectRequest - { - OutgoingTrustUkprn = "12387123", - TransferringAcademies = transferringAcademiesRequests, - }; - - var expectedTransferringAcademies = transferringAcademiesRequests.Select(ta => new TransferringAcademies - { - OutgoingAcademyUkprn = ta.OutgoingAcademyUkprn, - IncomingTrustUkprn = ta.IncomingTrustUkprn, - PupilNumbersAdditionalInformation = ta.PupilNumbersAdditionalInformation, - LatestOfstedReportAdditionalInformation = ta.LatestOfstedReportAdditionalInformation, - KeyStage2PerformanceAdditionalInformation = ta.KeyStage2PerformanceAdditionalInformation, - KeyStage4PerformanceAdditionalInformation = ta.KeyStage4PerformanceAdditionalInformation, - KeyStage5PerformanceAdditionalInformation = ta.KeyStage5PerformanceAdditionalInformation - }).ToList(); - - var expected = new AcademyTransferProjects - { - Id = academyTransferProject.Id, - Urn = academyTransferProject.Urn, - ProjectReference = academyTransferProject.ProjectReference, - OutgoingTrustUkprn = updateRequest.OutgoingTrustUkprn, - ProjectRationale = academyTransferProject.ProjectRationale, - TransferringAcademies = expectedTransferringAcademies, - WhoInitiatedTheTransfer = academyTransferProject.WhoInitiatedTheTransfer, - TargetDateForTransfer = academyTransferProject.TargetDateForTransfer, - RddOrEsfaIntervention = academyTransferProject.RddOrEsfaIntervention, - RddOrEsfaInterventionDetail = academyTransferProject.RddOrEsfaInterventionDetail, - TypeOfTransfer = academyTransferProject.TypeOfTransfer, - OtherTransferTypeDescription = academyTransferProject.OtherTransferTypeDescription, - TransferFirstDiscussed = academyTransferProject.TransferFirstDiscussed, - HtbDate = academyTransferProject.HtbDate, - TrustSponsorRationale = academyTransferProject.TrustSponsorRationale, - State = academyTransferProject.State, - Status = academyTransferProject.Status, - Author = academyTransferProject.Author, - Recommendation = academyTransferProject.Recommendation, - AnyRisks = academyTransferProject.AnyRisks, - HighProfileShouldBeConsidered = academyTransferProject.HighProfileShouldBeConsidered, - HighProfileFurtherSpecification = academyTransferProject.HighProfileFurtherSpecification, - ComplexLandAndBuildingShouldBeConsidered = - academyTransferProject.ComplexLandAndBuildingShouldBeConsidered, - ComplexLandAndBuildingFurtherSpecification = - academyTransferProject.ComplexLandAndBuildingFurtherSpecification, - FinanceAndDebtShouldBeConsidered = academyTransferProject.FinanceAndDebtShouldBeConsidered, - FinanceAndDebtFurtherSpecification = academyTransferProject.FinanceAndDebtFurtherSpecification, - OtherRisksShouldBeConsidered = academyTransferProject.OtherRisksShouldBeConsidered, - OtherRisksFurtherSpecification = academyTransferProject.OtherRisksFurtherSpecification, - OtherBenefitValue = academyTransferProject.OtherBenefitValue, - EqualitiesImpactAssessmentConsidered = academyTransferProject.EqualitiesImpactAssessmentConsidered, - IncomingTrustAgreement = academyTransferProject.IncomingTrustAgreement, - DiocesanConsent = academyTransferProject.DiocesanConsent, - OutgoingTrustConsent = academyTransferProject.OutgoingTrustConsent, - FeatureSectionIsCompleted = academyTransferProject.FeatureSectionIsCompleted, - BenefitsSectionIsCompleted = academyTransferProject.BenefitsSectionIsCompleted, - LegalRequirementsSectionIsCompleted = academyTransferProject.LegalRequirementsSectionIsCompleted, - RationaleSectionIsCompleted = academyTransferProject.RationaleSectionIsCompleted, - AcademyTransferProjectIntendedTransferBenefits = - academyTransferProject.AcademyTransferProjectIntendedTransferBenefits, - HasHtbDate = academyTransferProject.HasHtbDate, - HasTransferFirstDiscussedDate = academyTransferProject.HasTransferFirstDiscussedDate, - HasTargetDateForTransfer = academyTransferProject.HasTargetDateForTransfer, - AssignedUserEmailAddress = academyTransferProject.AssignedUserEmailAddress, - AssignedUserFullName = academyTransferProject.AssignedUserFullName, - AssignedUserId = academyTransferProject.AssignedUserId, - - CreatedOn = academyTransferProject.CreatedOn - }; - - var result = AcademyTransferProjectFactory.Update(academyTransferProject, updateRequest); - - result.Should().BeEquivalentTo(expected); - } - - [Fact] - public void ReturnsUpdatedAcademyTransferProject_WhenUpdating_IfRequestHasUpdatedSelectedBenefitsRequests() - { - var academyTransferProject = Builder - .CreateNew() - .With(atp => - atp.AcademyTransferProjectIntendedTransferBenefits = - Builder.CreateListOfSize(5).Build()) - .Build(); - - var updatedBenefits = academyTransferProject.AcademyTransferProjectIntendedTransferBenefits - .Select(benefit => benefit.SelectedBenefit) - .ToList(); - updatedBenefits.Insert(0, "A completely new benefit"); - - var updateRequest = new AcademyTransferProjectRequest - { - State = "A New State", - Benefits = new AcademyTransferProjectBenefitsRequest - { - IntendedTransferBenefits = new IntendedTransferBenefitRequest - { - SelectedBenefits = updatedBenefits, - } - } - }; - - var expectedBenefits = updateRequest.Benefits.IntendedTransferBenefits.SelectedBenefits - .Select(selectedBenefit => new AcademyTransferProjectIntendedTransferBenefits - {SelectedBenefit = selectedBenefit}) - .ToList(); - - var expected = new AcademyTransferProjects - { - Id = academyTransferProject.Id, - Urn = academyTransferProject.Urn, - ProjectReference = academyTransferProject.ProjectReference, - OutgoingTrustUkprn = academyTransferProject.OutgoingTrustUkprn, - ProjectRationale = academyTransferProject.ProjectRationale, - TransferringAcademies = academyTransferProject.TransferringAcademies, - WhoInitiatedTheTransfer = academyTransferProject.WhoInitiatedTheTransfer, - TargetDateForTransfer = academyTransferProject.TargetDateForTransfer, - RddOrEsfaIntervention = academyTransferProject.RddOrEsfaIntervention, - RddOrEsfaInterventionDetail = academyTransferProject.RddOrEsfaInterventionDetail, - TypeOfTransfer = academyTransferProject.TypeOfTransfer, - OtherTransferTypeDescription = academyTransferProject.OtherTransferTypeDescription, - TransferFirstDiscussed = academyTransferProject.TransferFirstDiscussed, - HtbDate = academyTransferProject.HtbDate, - TrustSponsorRationale = academyTransferProject.TrustSponsorRationale, - State = updateRequest.State, - Status = academyTransferProject.Status, - Author = academyTransferProject.Author, - Recommendation = academyTransferProject.Recommendation, - AnyRisks = academyTransferProject.AnyRisks, - HighProfileShouldBeConsidered = academyTransferProject.HighProfileShouldBeConsidered, - HighProfileFurtherSpecification = academyTransferProject.HighProfileFurtherSpecification, - ComplexLandAndBuildingShouldBeConsidered = - academyTransferProject.ComplexLandAndBuildingShouldBeConsidered, - ComplexLandAndBuildingFurtherSpecification = - academyTransferProject.ComplexLandAndBuildingFurtherSpecification, - FinanceAndDebtShouldBeConsidered = academyTransferProject.FinanceAndDebtShouldBeConsidered, - FinanceAndDebtFurtherSpecification = academyTransferProject.FinanceAndDebtFurtherSpecification, - OtherRisksShouldBeConsidered = academyTransferProject.OtherRisksShouldBeConsidered, - OtherRisksFurtherSpecification = academyTransferProject.OtherRisksFurtherSpecification, - OtherBenefitValue = academyTransferProject.OtherBenefitValue, - EqualitiesImpactAssessmentConsidered = academyTransferProject.EqualitiesImpactAssessmentConsidered, - IncomingTrustAgreement = academyTransferProject.IncomingTrustAgreement, - DiocesanConsent = academyTransferProject.DiocesanConsent, - OutgoingTrustConsent = academyTransferProject.OutgoingTrustConsent, - FeatureSectionIsCompleted = academyTransferProject.FeatureSectionIsCompleted, - BenefitsSectionIsCompleted = academyTransferProject.BenefitsSectionIsCompleted, - RationaleSectionIsCompleted = academyTransferProject.RationaleSectionIsCompleted, - LegalRequirementsSectionIsCompleted = academyTransferProject.LegalRequirementsSectionIsCompleted, - AcademyTransferProjectIntendedTransferBenefits = expectedBenefits, - HasHtbDate = academyTransferProject.HasHtbDate, - HasTransferFirstDiscussedDate = academyTransferProject.HasTransferFirstDiscussedDate, - HasTargetDateForTransfer = academyTransferProject.HasTargetDateForTransfer, - AssignedUserEmailAddress = academyTransferProject.AssignedUserEmailAddress, - AssignedUserFullName = academyTransferProject.AssignedUserFullName, - AssignedUserId = academyTransferProject.AssignedUserId, - - CreatedOn = academyTransferProject.CreatedOn - }; - - var result = AcademyTransferProjectFactory.Update(academyTransferProject, updateRequest); - - result.Should().BeEquivalentTo(expected); - } - - [Fact] - public void ReturnsUpdatedAcademyTransferProject_WhenUpdating_IfRequestIsToSetDatesBackToNull() - { - var academyTransferProject = Builder - .CreateNew() - .Build(); - - var updateRequest = new AcademyTransferProjectRequest - { - Dates = new AcademyTransferProjectDatesRequest - { - HasTargetDateForTransfer = false, - HasTransferFirstDiscussedDate = false, - HasHtbDate = false - } - }; - - var expected = new AcademyTransferProjects - { - Id = academyTransferProject.Id, - Urn = academyTransferProject.Urn, - ProjectReference = academyTransferProject.ProjectReference, - OutgoingTrustUkprn = academyTransferProject.OutgoingTrustUkprn, - ProjectRationale = academyTransferProject.ProjectRationale, - TransferringAcademies = academyTransferProject.TransferringAcademies, - WhoInitiatedTheTransfer = academyTransferProject.WhoInitiatedTheTransfer, - TargetDateForTransfer = null, - RddOrEsfaIntervention = academyTransferProject.RddOrEsfaIntervention, - RddOrEsfaInterventionDetail = academyTransferProject.RddOrEsfaInterventionDetail, - TypeOfTransfer = academyTransferProject.TypeOfTransfer, - OtherTransferTypeDescription = academyTransferProject.OtherTransferTypeDescription, - TransferFirstDiscussed = null, - HtbDate = null, - TrustSponsorRationale = academyTransferProject.TrustSponsorRationale, - State = academyTransferProject.State, - Status = academyTransferProject.Status, - Author = academyTransferProject.Author, - Recommendation = academyTransferProject.Recommendation, - AnyRisks = academyTransferProject.AnyRisks, - HighProfileShouldBeConsidered = academyTransferProject.HighProfileShouldBeConsidered, - HighProfileFurtherSpecification = academyTransferProject.HighProfileFurtherSpecification, - ComplexLandAndBuildingShouldBeConsidered = - academyTransferProject.ComplexLandAndBuildingShouldBeConsidered, - ComplexLandAndBuildingFurtherSpecification = - academyTransferProject.ComplexLandAndBuildingFurtherSpecification, - FinanceAndDebtShouldBeConsidered = academyTransferProject.FinanceAndDebtShouldBeConsidered, - FinanceAndDebtFurtherSpecification = academyTransferProject.FinanceAndDebtFurtherSpecification, - OtherRisksShouldBeConsidered = academyTransferProject.OtherRisksShouldBeConsidered, - OtherRisksFurtherSpecification = academyTransferProject.OtherRisksFurtherSpecification, - OtherBenefitValue = academyTransferProject.OtherBenefitValue, - EqualitiesImpactAssessmentConsidered = academyTransferProject.EqualitiesImpactAssessmentConsidered, - IncomingTrustAgreement = academyTransferProject.IncomingTrustAgreement, - DiocesanConsent = academyTransferProject.DiocesanConsent, - OutgoingTrustConsent = academyTransferProject.OutgoingTrustConsent, - FeatureSectionIsCompleted = academyTransferProject.FeatureSectionIsCompleted, - BenefitsSectionIsCompleted = academyTransferProject.BenefitsSectionIsCompleted, - LegalRequirementsSectionIsCompleted = academyTransferProject.LegalRequirementsSectionIsCompleted, - RationaleSectionIsCompleted = academyTransferProject.RationaleSectionIsCompleted, - AcademyTransferProjectIntendedTransferBenefits = - academyTransferProject.AcademyTransferProjectIntendedTransferBenefits, - HasTransferFirstDiscussedDate = false, - HasHtbDate = false, - HasTargetDateForTransfer = false, - AssignedUserEmailAddress = academyTransferProject.AssignedUserEmailAddress, - AssignedUserFullName = academyTransferProject.AssignedUserFullName, - AssignedUserId = academyTransferProject.AssignedUserId, - - CreatedOn = academyTransferProject.CreatedOn - }; - - var result = AcademyTransferProjectFactory.Update(academyTransferProject, updateRequest); - - result.Should().BeEquivalentTo(expected); - } - - [Fact] - public void ReturnsOriginalAcademyTransferProjectWithDatesSetToNull_WhenUpdating_IfHasDateFieldsAreFalse() - { - var randomGenerator = new RandomGenerator(); - - var academyTransferProject = Builder - .CreateNew() - .Build(); - - var updateRequest = new AcademyTransferProjectRequest - { - Dates = new AcademyTransferProjectDatesRequest - { - TargetDateForTransfer = - randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture), - TransferFirstDiscussed = - randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture), - HtbDate = randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture), - HasHtbDate = false, - HasTargetDateForTransfer = false, - HasTransferFirstDiscussedDate = false - } - }; - - var expected = new AcademyTransferProjects - { - Id = academyTransferProject.Id, - Urn = academyTransferProject.Urn, - ProjectReference = academyTransferProject.ProjectReference, - OutgoingTrustUkprn = academyTransferProject.OutgoingTrustUkprn, - ProjectRationale = academyTransferProject.ProjectRationale, - TransferringAcademies = academyTransferProject.TransferringAcademies, - WhoInitiatedTheTransfer = academyTransferProject.WhoInitiatedTheTransfer, - TargetDateForTransfer = null, - RddOrEsfaIntervention = academyTransferProject.RddOrEsfaIntervention, - RddOrEsfaInterventionDetail = academyTransferProject.RddOrEsfaInterventionDetail, - TypeOfTransfer = academyTransferProject.TypeOfTransfer, - OtherTransferTypeDescription = academyTransferProject.OtherTransferTypeDescription, - TransferFirstDiscussed = null, - HtbDate = null, - TrustSponsorRationale = academyTransferProject.TrustSponsorRationale, - State = academyTransferProject.State, - Status = academyTransferProject.Status, - Author = academyTransferProject.Author, - Recommendation = academyTransferProject.Recommendation, - AnyRisks = academyTransferProject.AnyRisks, - HighProfileShouldBeConsidered = academyTransferProject.HighProfileShouldBeConsidered, - HighProfileFurtherSpecification = academyTransferProject.HighProfileFurtherSpecification, - ComplexLandAndBuildingShouldBeConsidered = - academyTransferProject.ComplexLandAndBuildingShouldBeConsidered, - ComplexLandAndBuildingFurtherSpecification = - academyTransferProject.ComplexLandAndBuildingFurtherSpecification, - FinanceAndDebtShouldBeConsidered = academyTransferProject.FinanceAndDebtShouldBeConsidered, - FinanceAndDebtFurtherSpecification = academyTransferProject.FinanceAndDebtFurtherSpecification, - OtherRisksShouldBeConsidered = academyTransferProject.OtherRisksShouldBeConsidered, - OtherRisksFurtherSpecification = academyTransferProject.OtherRisksFurtherSpecification, - OtherBenefitValue = academyTransferProject.OtherBenefitValue, - IncomingTrustAgreement = academyTransferProject.IncomingTrustAgreement, - DiocesanConsent = academyTransferProject.DiocesanConsent, - OutgoingTrustConsent = academyTransferProject.OutgoingTrustConsent, - EqualitiesImpactAssessmentConsidered = academyTransferProject.EqualitiesImpactAssessmentConsidered, - FeatureSectionIsCompleted = academyTransferProject.FeatureSectionIsCompleted, - BenefitsSectionIsCompleted = academyTransferProject.BenefitsSectionIsCompleted, - LegalRequirementsSectionIsCompleted = academyTransferProject.LegalRequirementsSectionIsCompleted, - RationaleSectionIsCompleted = academyTransferProject.RationaleSectionIsCompleted, - AcademyTransferProjectIntendedTransferBenefits = - academyTransferProject.AcademyTransferProjectIntendedTransferBenefits, - HasTransferFirstDiscussedDate = false, - HasHtbDate = false, - HasTargetDateForTransfer = false, - AssignedUserEmailAddress = academyTransferProject.AssignedUserEmailAddress, - AssignedUserFullName = academyTransferProject.AssignedUserFullName, - AssignedUserId = academyTransferProject.AssignedUserId, - CreatedOn = academyTransferProject.CreatedOn - }; - - AcademyTransferProjects result = AcademyTransferProjectFactory.Update(academyTransferProject, updateRequest); - - result.Should().BeEquivalentTo(expected); - } - } -} diff --git a/TramsDataApi.Test/Factories/AcademyTransferProjectResponseFactoryTests.cs b/TramsDataApi.Test/Factories/AcademyTransferProjectResponseFactoryTests.cs deleted file mode 100644 index d5e0d4ce..00000000 --- a/TramsDataApi.Test/Factories/AcademyTransferProjectResponseFactoryTests.cs +++ /dev/null @@ -1,234 +0,0 @@ -using System.Globalization; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using TramsDataApi.DatabaseModels; -using TramsDataApi.Factories; -using TramsDataApi.ResponseModels; -using TramsDataApi.ResponseModels.AcademyTransferProject; -using Xunit; - -namespace TramsDataApi.Test.Factories -{ - public class AcademyTransferProjectResponseFactoryTests - { - [Fact] - public void ReturnsAnAcademyTransferProjectResponse_WhenGivenAnInitialAcademyTransferProject() - { - var academyTransferProjectModel = new AcademyTransferProjects - { - Urn = 0, - OutgoingTrustUkprn = "00000001", - WhoInitiatedTheTransfer = null, - RddOrEsfaIntervention = null, - RddOrEsfaInterventionDetail = null, - TypeOfTransfer = null, - OtherTransferTypeDescription = null, - TransferFirstDiscussed = null, - TargetDateForTransfer = null, - HtbDate = null, - ProjectRationale = null, - TrustSponsorRationale = null, - HasHtbDate = null, - HasTransferFirstDiscussedDate = null, - HasTargetDateForTransfer = null, - State = null, - Status = null, - Author = null, - Recommendation = null, - AnyRisks = null, - HighProfileShouldBeConsidered = null, - HighProfileFurtherSpecification = null, - ComplexLandAndBuildingShouldBeConsidered = null, - ComplexLandAndBuildingFurtherSpecification = null, - FinanceAndDebtShouldBeConsidered = null, - FinanceAndDebtFurtherSpecification = null, - OtherRisksShouldBeConsidered = null, - OtherRisksFurtherSpecification = null, - OtherBenefitValue = null, - FeatureSectionIsCompleted = null, - BenefitsSectionIsCompleted = null, - LegalRequirementsSectionIsCompleted = null, - RationaleSectionIsCompleted = null, - AcademyTransferProjectIntendedTransferBenefits = null, - TransferringAcademies = Builder - .CreateListOfSize(1).All() - .With(ta => ta.IncomingTrustUkprn = null) - .Build() - }; - - var expected = new AcademyTransferProjectResponse - { - ProjectUrn = academyTransferProjectModel.Urn.ToString(), - OutgoingTrustUkprn = academyTransferProjectModel.OutgoingTrustUkprn, - TransferringAcademies = academyTransferProjectModel.TransferringAcademies.Select(ta => - new TransferringAcademiesResponse - { - IncomingTrustUkprn = null, - OutgoingAcademyUkprn = ta.OutgoingAcademyUkprn, - PupilNumbersAdditionalInformation = ta.PupilNumbersAdditionalInformation, - LatestOfstedReportAdditionalInformation = ta.LatestOfstedReportAdditionalInformation, - KeyStage2PerformanceAdditionalInformation = ta.KeyStage2PerformanceAdditionalInformation, - KeyStage4PerformanceAdditionalInformation = ta.KeyStage4PerformanceAdditionalInformation, - KeyStage5PerformanceAdditionalInformation = ta.KeyStage5PerformanceAdditionalInformation - }).ToList(), - Features = new AcademyTransferProjectFeaturesResponse(), - Dates = new AcademyTransferProjectDatesResponse(), - Benefits = new AcademyTransferProjectBenefitsResponse - { - IntendedTransferBenefits = new IntendedTransferBenefitResponse(), - OtherFactorsToConsider = new OtherFactorsToConsiderResponse - { - HighProfile = new BenefitConsideredFactorResponse(), - ComplexLandAndBuilding = new BenefitConsideredFactorResponse(), - FinanceAndDebt = new BenefitConsideredFactorResponse(), - OtherRisks = new BenefitConsideredFactorResponse() - }, - IsCompleted = null, - AnyRisks = null - }, - LegalRequirements = new AcademyTransferProjectLegalRequirementsResponse - { - IncomingTrustAgreement = null, - DiocesanConsent = null, - OutgoingTrustConsent = null, - IsCompleted = null, - }, - Rationale = new AcademyTransferProjectRationaleResponse(), - GeneralInformation = new AcademyTransferProjectGeneralInformationResponse(), - State = null, - Status = null, - AssignedUser = null, - }; - - var result = AcademyTransferProjectResponseFactory.Create(academyTransferProjectModel); - - result.Should().BeEquivalentTo(expected); - } - - [Fact] - public void ReturnsAnAcademyTransferProjectResponse_WhenGivenACompleteAcademyTransferProject() - { - var academyTransferProjectModel = Builder.CreateNew().Build(); - - var expectedTransferringAcademies = academyTransferProjectModel.TransferringAcademies - .Select(a => new TransferringAcademiesResponse - { - IncomingTrustUkprn = a.IncomingTrustUkprn, - OutgoingAcademyUkprn = a.OutgoingAcademyUkprn, - PupilNumbersAdditionalInformation = a.PupilNumbersAdditionalInformation, - LatestOfstedReportAdditionalInformation = a.LatestOfstedReportAdditionalInformation, - KeyStage2PerformanceAdditionalInformation = a.KeyStage2PerformanceAdditionalInformation, - KeyStage4PerformanceAdditionalInformation = a.KeyStage4PerformanceAdditionalInformation, - KeyStage5PerformanceAdditionalInformation = a.KeyStage5PerformanceAdditionalInformation - }) - .ToList(); - - var expectedFeatures = new AcademyTransferProjectFeaturesResponse - { - WhoInitiatedTheTransfer = academyTransferProjectModel.WhoInitiatedTheTransfer, - RddOrEsfaIntervention = academyTransferProjectModel.RddOrEsfaIntervention, - RddOrEsfaInterventionDetail = academyTransferProjectModel.RddOrEsfaInterventionDetail, - TypeOfTransfer = academyTransferProjectModel.TypeOfTransfer, - OtherTransferTypeDescription = academyTransferProjectModel.OtherTransferTypeDescription, - IsCompleted = academyTransferProjectModel.FeatureSectionIsCompleted - }; - - var expectedDates = new AcademyTransferProjectDatesResponse - { - TransferFirstDiscussed = academyTransferProjectModel.TransferFirstDiscussed?.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture), - TargetDateForTransfer = academyTransferProjectModel.TargetDateForTransfer?.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture), - HtbDate = academyTransferProjectModel.HtbDate?.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture), - HasHtbDate = academyTransferProjectModel.HasHtbDate, - HasTransferFirstDiscussedDate = academyTransferProjectModel.HasTransferFirstDiscussedDate, - HasTargetDateForTransfer = academyTransferProjectModel.HasTargetDateForTransfer - }; - - var expectedIntendedTransferBenefits = new IntendedTransferBenefitResponse - { - OtherBenefitValue = academyTransferProjectModel.OtherBenefitValue, - SelectedBenefits = academyTransferProjectModel.AcademyTransferProjectIntendedTransferBenefits - .Select(b => b.SelectedBenefit).ToList() - }; - - var expectedOtherFactorsToConsider = new OtherFactorsToConsiderResponse - { - HighProfile = new BenefitConsideredFactorResponse - { - ShouldBeConsidered = academyTransferProjectModel.HighProfileShouldBeConsidered, - FurtherSpecification = academyTransferProjectModel.HighProfileFurtherSpecification - }, - ComplexLandAndBuilding = new BenefitConsideredFactorResponse - { - ShouldBeConsidered = academyTransferProjectModel.ComplexLandAndBuildingShouldBeConsidered, - FurtherSpecification = academyTransferProjectModel.ComplexLandAndBuildingFurtherSpecification - }, - FinanceAndDebt = new BenefitConsideredFactorResponse - { - ShouldBeConsidered = academyTransferProjectModel.FinanceAndDebtShouldBeConsidered, - FurtherSpecification = academyTransferProjectModel.FinanceAndDebtFurtherSpecification - }, - OtherRisks = new BenefitConsideredFactorResponse - { - ShouldBeConsidered = academyTransferProjectModel.OtherRisksShouldBeConsidered, - FurtherSpecification = academyTransferProjectModel.OtherRisksFurtherSpecification - } - }; - - var expected = new AcademyTransferProjectResponse - { - ProjectUrn = academyTransferProjectModel.Urn.ToString(), - ProjectReference = academyTransferProjectModel.ProjectReference, - OutgoingTrustUkprn = academyTransferProjectModel.OutgoingTrustUkprn, - TransferringAcademies = expectedTransferringAcademies, - Features = expectedFeatures, - Dates = expectedDates, - Benefits = new AcademyTransferProjectBenefitsResponse - { - IntendedTransferBenefits = expectedIntendedTransferBenefits, - OtherFactorsToConsider = expectedOtherFactorsToConsider, - EqualitiesImpactAssessmentConsidered = academyTransferProjectModel.EqualitiesImpactAssessmentConsidered, - IsCompleted = academyTransferProjectModel.BenefitsSectionIsCompleted, - AnyRisks = academyTransferProjectModel.AnyRisks - }, - LegalRequirements = new AcademyTransferProjectLegalRequirementsResponse - { - IncomingTrustAgreement = academyTransferProjectModel.IncomingTrustAgreement, - DiocesanConsent = academyTransferProjectModel.DiocesanConsent, - OutgoingTrustConsent = academyTransferProjectModel.OutgoingTrustConsent, - IsCompleted = academyTransferProjectModel.LegalRequirementsSectionIsCompleted, - }, - Rationale = new AcademyTransferProjectRationaleResponse - { - ProjectRationale = academyTransferProjectModel.ProjectRationale, - TrustSponsorRationale = academyTransferProjectModel.TrustSponsorRationale, - IsCompleted = academyTransferProjectModel.RationaleSectionIsCompleted - }, - GeneralInformation = new AcademyTransferProjectGeneralInformationResponse - { - Author = academyTransferProjectModel.Author, - Recommendation = academyTransferProjectModel.Recommendation - }, - AssignedUser = new AssignedUserResponse - { - EmailAddress = academyTransferProjectModel.AssignedUserEmailAddress, - FullName = academyTransferProjectModel.AssignedUserFullName, - Id = academyTransferProjectModel.AssignedUserId - }, - State = academyTransferProjectModel.State, - Status = academyTransferProjectModel.Status - }; - - var result = AcademyTransferProjectResponseFactory.Create(academyTransferProjectModel); - - result.Should().BeEquivalentTo(expected); - } - - [Fact] - public void ReturnsNull_WhenGivenANullValue() - { - var result = AcademyTransferProjectResponseFactory.Create(null); - result.Should().BeNull(); - } - } -} diff --git a/TramsDataApi.Test/Integration/AcademyTransferProjectIntegrationTests.cs b/TramsDataApi.Test/Integration/AcademyTransferProjectIntegrationTests.cs deleted file mode 100644 index 1782a0b9..00000000 --- a/TramsDataApi.Test/Integration/AcademyTransferProjectIntegrationTests.cs +++ /dev/null @@ -1,856 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Threading.Tasks; -using FizzWare.NBuilder; -using FluentAssertions; -using Microsoft.Extensions.DependencyInjection; -using Newtonsoft.Json; -using TramsDataApi.DatabaseModels; -using TramsDataApi.RequestModels; -using Xunit; -using System.Net.Http.Json; -using Microsoft.EntityFrameworkCore; -using TramsDataApi.Factories; -using TramsDataApi.RequestModels.AcademyTransferProject; -using TramsDataApi.ResponseModels.AcademyTransferProject; - -namespace TramsDataApi.Test.Integration -{ - [Collection("Database")] - public class AcademyTransferProjectIntegrationTests : IClassFixture, IDisposable - { - private readonly HttpClient _client; - private readonly LegacyTramsDbContext _legacyTramsDbContext; - private readonly TramsDbContext _tramsDbContext; - - private const int numberOfProjectsPerPage = 10; - - public AcademyTransferProjectIntegrationTests(TramsDataApiFactory fixture) - { - _client = fixture.CreateClient(); - _client.BaseAddress = new Uri("https://trams-api.com/"); - _legacyTramsDbContext = fixture.Services.GetRequiredService(); - _tramsDbContext = fixture.Services.GetRequiredService(); - } - - [Fact] - public async Task CanCreateAnInitialAcademyTransferProject() - { - var randomGenerator = new RandomGenerator(); - - var createRequest = Builder.CreateNew() - .With(c => c.OutgoingTrustUkprn = randomGenerator.NextString(8, 8)) - .With(c => c.Benefits = null) - .With(c => c.Dates = null) - .With(c => c.Rationale = null) - .With(c => c.GeneralInformation = null) - .With(c => c.Features = null) - .With(c => c.TransferringAcademies = - (List) Builder - .CreateListOfSize(5).All() - .With(ta => ta.OutgoingAcademyUkprn = randomGenerator.NextString(8, 8)) - .With(ta => ta.IncomingTrustUkprn = null).Build()) - .Build(); - - var httpRequestMessage = new HttpRequestMessage - { - Method = HttpMethod.Post, - RequestUri = new Uri($"https://trams-api.com/academyTransferProject"), - Headers = - { - {"ApiKey", "testing-api-key"} - }, - Content = JsonContent.Create(createRequest) - }; - - var response = await _client.SendAsync(httpRequestMessage); - response.StatusCode.Should().Be(HttpStatusCode.Created); - var jsonString = await response.Content.ReadAsStringAsync(); - var result = JsonConvert.DeserializeObject(jsonString); - - var createdProject = - _tramsDbContext.AcademyTransferProjects.FirstOrDefault(atp => atp.Urn.ToString() == result.ProjectUrn); - createdProject.Should().NotBe(null); - createdProject.OutgoingTrustUkprn.Should().BeEquivalentTo(createRequest.OutgoingTrustUkprn); - } - - [Fact] - public async Task CanCreateAFullAcademyTransferProject() - { - var randomGenerator = new RandomGenerator(); - - var benefitsRequest = Builder.CreateNew() - .With(b => b.IntendedTransferBenefits = Builder.CreateNew() - .With(i => i.SelectedBenefits = new List()).Build()) - .With(b => b.OtherFactorsToConsider = Builder.CreateNew() - .With(o => o.ComplexLandAndBuilding = Builder.CreateNew().Build()) - .With(o => o.FinanceAndDebt = Builder.CreateNew().Build()) - .With(o => o.HighProfile = Builder.CreateNew().Build()).Build()) - .Build(); - - var datesRequest = Builder.CreateNew() - .With(d => d.TransferFirstDiscussed = - randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)) - .With(d => d.TargetDateForTransfer = - randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)) - .With(d => d.HtbDate = randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)) - .With(d => d.HasHtbDate = true) - .With(d => d.HasTargetDateForTransfer = true) - .With(d => d.HasTransferFirstDiscussedDate = true) - .Build(); - - var createRequest = Builder.CreateNew() - .With(c => c.OutgoingTrustUkprn = randomGenerator.NextString(8, 8)) - .With(c => c.Benefits = benefitsRequest) - .With(c => c.LegalRequirements = Builder.CreateNew().Build()) - .With(c => c.Dates = datesRequest) - .With(c => c.Rationale = Builder.CreateNew().Build()) - .With(c => c.GeneralInformation = - Builder.CreateNew().Build()) - .With(c => c.Features = Builder.CreateNew().Build()) - .With(c => c.TransferringAcademies = - (List) Builder - .CreateListOfSize(5).All() - .With(ta => ta.IncomingTrustUkprn = randomGenerator.NextString(8, 8)) - .With(ta => ta.OutgoingAcademyUkprn = randomGenerator.NextString(8, 8)).Build()) - .Build(); - - var httpRequestMessage = new HttpRequestMessage - { - Method = HttpMethod.Post, - RequestUri = new Uri($"https://trams-api.com/academyTransferProject"), - Headers = - { - {"ApiKey", "testing-api-key"} - }, - Content = JsonContent.Create(createRequest) - }; - - var response = await _client.SendAsync(httpRequestMessage); - response.StatusCode.Should().Be(HttpStatusCode.Created); - var jsonString = await response.Content.ReadAsStringAsync(); - var result = JsonConvert.DeserializeObject(jsonString); - - var createdProject = - _tramsDbContext.AcademyTransferProjects.FirstOrDefault(atp => atp.Urn.ToString() == result.ProjectUrn); - createdProject.Should().NotBe(null); - createdProject.OutgoingTrustUkprn.Should().BeEquivalentTo(createRequest.OutgoingTrustUkprn); - } - - [Fact] - public async Task CanUpdateAnAcademyTransferProject() - { - var randomGenerator = new RandomGenerator(); - - var benefitsRequest = Builder.CreateNew() - .With(b => b.IntendedTransferBenefits = Builder.CreateNew() - .With(i => i.SelectedBenefits = new List()).Build()) - .With(b => b.OtherFactorsToConsider = Builder.CreateNew() - .With(o => o.ComplexLandAndBuilding = Builder.CreateNew().Build()) - .With(o => o.FinanceAndDebt = Builder.CreateNew().Build()) - .With(o => o.HighProfile = Builder.CreateNew().Build()).Build()) - .Build(); - - var datesRequest = Builder.CreateNew() - .With(d => d.TransferFirstDiscussed = - randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)) - .With(d => d.TargetDateForTransfer = - randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)) - .With(d => d.HtbDate = randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)) - .With(d => d.HasHtbDate = true) - .With(d => d.HasTargetDateForTransfer = true) - .With(d => d.HasTransferFirstDiscussedDate = true) - .Build(); - - var createRequest = Builder.CreateNew() - .With(c => c.OutgoingTrustUkprn = randomGenerator.NextString(8, 8)) - .With(c => c.Benefits = benefitsRequest) - .With(c => c.Dates = datesRequest) - .With(c => c.Rationale = Builder.CreateNew().Build()) - .With(c => c.GeneralInformation = - Builder.CreateNew().Build()) - .With(c => c.Features = Builder.CreateNew().Build()) - .With(c => c.TransferringAcademies = - (List) Builder - .CreateListOfSize(5).All() - .With(ta => ta.IncomingTrustUkprn = randomGenerator.NextString(8, 8)) - .With(ta => ta.OutgoingAcademyUkprn = randomGenerator.NextString(8, 8)).Build()) - .Build(); - - var httpRequestMessage = new HttpRequestMessage - { - Method = HttpMethod.Post, - RequestUri = new Uri($"https://trams-api.com/academyTransferProject"), - Headers = - { - {"ApiKey", "testing-api-key"} - }, - Content = JsonContent.Create(createRequest) - }; - - var response = await _client.SendAsync(httpRequestMessage); - response.StatusCode.Should().Be(HttpStatusCode.Created); - var jsonString = await response.Content.ReadAsStringAsync(); - var result = JsonConvert.DeserializeObject(jsonString); - - createRequest.OutgoingTrustUkprn = "14567231"; - - var updateRequestMessage = new HttpRequestMessage - { - Method = HttpMethod.Patch, - RequestUri = new Uri($"https://trams-api.com/academyTransferProject/{result.ProjectUrn}"), - Headers = - { - {"ApiKey", "testing-api-key"} - }, - Content = JsonContent.Create(createRequest) - }; - - var updateResponse = await _client.SendAsync(updateRequestMessage); - updateResponse.StatusCode.Should().Be(HttpStatusCode.OK); - var updateJson = await updateResponse.Content.ReadAsStringAsync(); - var updatedProjectResponse = JsonConvert.DeserializeObject(updateJson); - - var updatedProject = - _tramsDbContext.AcademyTransferProjects.FirstOrDefault(atp => - atp.Urn.ToString() == updatedProjectResponse.ProjectUrn); - updatedProject.OutgoingTrustUkprn.Should().Be(createRequest.OutgoingTrustUkprn); - } - - [Fact] - public async Task CanUpdateTheSelectedBenefitsOfAnAcademyTransferProject() - { - var randomGenerator = new RandomGenerator(); - - var benefitsRequest = Builder.CreateNew() - .With(b => b.IntendedTransferBenefits = Builder.CreateNew() - .With(i => i.SelectedBenefits = new List() {"Initial benefit", "other benefit"}).Build()) - .With(b => b.OtherFactorsToConsider = Builder.CreateNew() - .With(o => o.ComplexLandAndBuilding = Builder.CreateNew().Build()) - .With(o => o.FinanceAndDebt = Builder.CreateNew().Build()) - .With(o => o.HighProfile = Builder.CreateNew().Build()).Build()) - .Build(); - - var datesRequest = Builder.CreateNew() - .With(d => d.TransferFirstDiscussed = - randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)) - .With(d => d.TargetDateForTransfer = - randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)) - .With(d => d.HtbDate = randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)) - .With(d => d.HasHtbDate = true) - .With(d => d.HasTargetDateForTransfer = true) - .With(d => d.HasTransferFirstDiscussedDate = true) - .Build(); - - var createRequest = Builder.CreateNew() - .With(c => c.OutgoingTrustUkprn = randomGenerator.NextString(8, 8)) - .With(c => c.Benefits = benefitsRequest) - .With(c => c.Dates = datesRequest) - .With(c => c.Rationale = Builder.CreateNew().Build()) - .With(c => c.GeneralInformation = - Builder.CreateNew().Build()) - .With(c => c.Features = Builder.CreateNew().Build()) - .With(c => c.TransferringAcademies = - (List) Builder - .CreateListOfSize(1).All() - .With(ta => ta.IncomingTrustUkprn = randomGenerator.NextString(8, 8)) - .With(ta => ta.OutgoingAcademyUkprn = randomGenerator.NextString(8, 8)).Build()) - .Build(); - - _tramsDbContext.AcademyTransferProjectIntendedTransferBenefits.Count().Should().Be(0); - - var httpRequestMessage = new HttpRequestMessage - { - Method = HttpMethod.Post, - RequestUri = new Uri($"https://trams-api.com/academyTransferProject"), - Headers = - { - {"ApiKey", "testing-api-key"} - }, - Content = JsonContent.Create(createRequest) - }; - - var response = await _client.SendAsync(httpRequestMessage); - response.StatusCode.Should().Be(HttpStatusCode.Created); - var jsonString = await response.Content.ReadAsStringAsync(); - var result = JsonConvert.DeserializeObject(jsonString); - - createRequest.Benefits.IntendedTransferBenefits.SelectedBenefits = new List() - {"new initial benefit", "new other benefit"}; - - var updateRequestMessage = new HttpRequestMessage - { - Method = HttpMethod.Patch, - RequestUri = new Uri($"https://trams-api.com/academyTransferProject/{result.ProjectUrn}"), - Headers = - { - {"ApiKey", "testing-api-key"} - }, - Content = JsonContent.Create(createRequest) - }; - - var updateResponse = await _client.SendAsync(updateRequestMessage); - updateResponse.StatusCode.Should().Be(HttpStatusCode.OK); - var updateJson = await updateResponse.Content.ReadAsStringAsync(); - var updatedProjectResponse = JsonConvert.DeserializeObject(updateJson); - - var updatedProject = _tramsDbContext.AcademyTransferProjects - .Include(atp => atp.AcademyTransferProjectIntendedTransferBenefits) - .FirstOrDefault(atp => atp.Urn.ToString() == updatedProjectResponse.ProjectUrn); - - updatedProject?.AcademyTransferProjectIntendedTransferBenefits.Count.Should().Be(2); - _tramsDbContext.AcademyTransferProjectIntendedTransferBenefits.Count().Should().Be(2); - - updatedProject?.AcademyTransferProjectIntendedTransferBenefits - .ElementAt(0).SelectedBenefit.Should().Be("new initial benefit"); - updatedProject?.AcademyTransferProjectIntendedTransferBenefits - .ElementAt(1).SelectedBenefit.Should().Be("new other benefit"); - } - - [Fact] - public async Task CanUpdateTheTransferringAcademiesOfAnAcademyTransferProject() - { - var randomGenerator = new RandomGenerator(); - - var benefitsRequest = Builder.CreateNew() - .With(b => b.IntendedTransferBenefits = Builder.CreateNew() - .With(i => i.SelectedBenefits = new List()).Build()) - .With(b => b.OtherFactorsToConsider = Builder.CreateNew() - .With(o => o.ComplexLandAndBuilding = Builder.CreateNew().Build()) - .With(o => o.FinanceAndDebt = Builder.CreateNew().Build()) - .With(o => o.HighProfile = Builder.CreateNew().Build()).Build()) - .Build(); - - var datesRequest = Builder.CreateNew() - .With(d => d.TransferFirstDiscussed = - randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)) - .With(d => d.TargetDateForTransfer = - randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)) - .With(d => d.HtbDate = randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)) - .With(d => d.HasHtbDate = true) - .With(d => d.HasTargetDateForTransfer = true) - .With(d => d.HasTransferFirstDiscussedDate = true) - .Build(); - - var createRequest = Builder.CreateNew() - .With(c => c.OutgoingTrustUkprn = randomGenerator.NextString(8, 8)) - .With(c => c.Benefits = benefitsRequest) - .With(c => c.Dates = datesRequest) - .With(c => c.Rationale = Builder.CreateNew().Build()) - .With(c => c.GeneralInformation = - Builder.CreateNew().Build()) - .With(c => c.Features = Builder.CreateNew().Build()) - .With(c => c.TransferringAcademies = - (List) Builder - .CreateListOfSize(2).All() - .With(ta => ta.IncomingTrustUkprn = randomGenerator.NextString(8, 8)) - .With(ta => ta.OutgoingAcademyUkprn = randomGenerator.NextString(8, 8)) - .Build()) - .Build(); - - _tramsDbContext.TransferringAcademies.Count().Should().Be(0); - - var httpRequestMessage = new HttpRequestMessage - { - Method = HttpMethod.Post, - RequestUri = new Uri($"https://trams-api.com/academyTransferProject"), - Headers = - { - {"ApiKey", "testing-api-key"} - }, - Content = JsonContent.Create(createRequest) - }; - - var response = await _client.SendAsync(httpRequestMessage); - response.StatusCode.Should().Be(HttpStatusCode.Created); - var jsonString = await response.Content.ReadAsStringAsync(); - var result = JsonConvert.DeserializeObject(jsonString); - - createRequest.TransferringAcademies = new List() - { - new TransferringAcademiesRequest - { - OutgoingAcademyUkprn = "12345678", - IncomingTrustUkprn = "12345678", - PupilNumbersAdditionalInformation = "pupil info", - LatestOfstedReportAdditionalInformation = "ofsted info", - KeyStage2PerformanceAdditionalInformation = "ks2", - KeyStage4PerformanceAdditionalInformation = "ks4", - KeyStage5PerformanceAdditionalInformation = "ks5" - }, - new TransferringAcademiesRequest - { - OutgoingAcademyUkprn = "87654321", - IncomingTrustUkprn = "87654321", - PupilNumbersAdditionalInformation = "pupil info 2", - LatestOfstedReportAdditionalInformation = "ofsted info 2", - KeyStage2PerformanceAdditionalInformation = "ks2 2", - KeyStage4PerformanceAdditionalInformation = "ks4 2", - KeyStage5PerformanceAdditionalInformation = "ks5 2" - } - }; - - var updateRequestMessage = new HttpRequestMessage - { - Method = HttpMethod.Patch, - RequestUri = new Uri($"https://trams-api.com/academyTransferProject/{result.ProjectUrn}"), - Headers = - { - {"ApiKey", "testing-api-key"} - }, - Content = JsonContent.Create(createRequest) - }; - - var updateResponse = await _client.SendAsync(updateRequestMessage); - updateResponse.StatusCode.Should().Be(HttpStatusCode.OK); - var updateJson = await updateResponse.Content.ReadAsStringAsync(); - var updatedProjectResponse = JsonConvert.DeserializeObject(updateJson); - - var updatedProject = _tramsDbContext.AcademyTransferProjects - .Include(atp => atp.TransferringAcademies) - .FirstOrDefault(atp => atp.Urn.ToString() == updatedProjectResponse.ProjectUrn); - - updatedProject?.TransferringAcademies.Count.Should().Be(2); - _tramsDbContext.TransferringAcademies.Count().Should().Be(2); - - var firstCreateAcademy = createRequest.TransferringAcademies.ElementAt(0); - var secondCreateAcademy = createRequest.TransferringAcademies.ElementAt(1); - - updatedProject?.TransferringAcademies.ElementAt(0).IncomingTrustUkprn.Should().Be(firstCreateAcademy.IncomingTrustUkprn); - updatedProject?.TransferringAcademies.ElementAt(0).OutgoingAcademyUkprn.Should().Be(firstCreateAcademy.OutgoingAcademyUkprn); - updatedProject?.TransferringAcademies.ElementAt(0).LatestOfstedReportAdditionalInformation.Should().Be(firstCreateAcademy.LatestOfstedReportAdditionalInformation); - updatedProject?.TransferringAcademies.ElementAt(0).PupilNumbersAdditionalInformation.Should().Be(firstCreateAcademy.PupilNumbersAdditionalInformation); - updatedProject?.TransferringAcademies.ElementAt(0).KeyStage2PerformanceAdditionalInformation.Should().Be(firstCreateAcademy.KeyStage2PerformanceAdditionalInformation); - updatedProject?.TransferringAcademies.ElementAt(0).KeyStage4PerformanceAdditionalInformation.Should().Be(firstCreateAcademy.KeyStage4PerformanceAdditionalInformation); - updatedProject?.TransferringAcademies.ElementAt(0).KeyStage5PerformanceAdditionalInformation.Should().Be(firstCreateAcademy.KeyStage5PerformanceAdditionalInformation); - - updatedProject?.TransferringAcademies.ElementAt(1).IncomingTrustUkprn.Should().Be(secondCreateAcademy.IncomingTrustUkprn); - updatedProject?.TransferringAcademies.ElementAt(1).OutgoingAcademyUkprn.Should().Be(secondCreateAcademy.OutgoingAcademyUkprn); - updatedProject?.TransferringAcademies.ElementAt(1).LatestOfstedReportAdditionalInformation.Should().Be(secondCreateAcademy.LatestOfstedReportAdditionalInformation); - updatedProject?.TransferringAcademies.ElementAt(1).PupilNumbersAdditionalInformation.Should().Be(secondCreateAcademy.PupilNumbersAdditionalInformation); - updatedProject?.TransferringAcademies.ElementAt(1).KeyStage2PerformanceAdditionalInformation.Should().Be(secondCreateAcademy.KeyStage2PerformanceAdditionalInformation); - updatedProject?.TransferringAcademies.ElementAt(1).KeyStage4PerformanceAdditionalInformation.Should().Be(secondCreateAcademy.KeyStage4PerformanceAdditionalInformation); - updatedProject?.TransferringAcademies.ElementAt(1).KeyStage5PerformanceAdditionalInformation.Should().Be(secondCreateAcademy.KeyStage5PerformanceAdditionalInformation); - } - - [Fact] - public async Task CanGetTheFirstPageOfAllAcademyTransferProjects() - { - const int numberOfProjects = 20; - var randomGenerator = new RandomGenerator(); - - var groups = AddGroups(2); - var outgoingTrustGroup = groups[0]; - var incomingTrustGroup = groups[1]; - - var trusts = AddTrustsFromGroups(groups); - - var academyTransferProjectsToCreate = Builder - .CreateListOfSize(numberOfProjects) - .All() - .With(atp => atp.OutgoingTrustUkprn = outgoingTrustGroup.Ukprn) - .With(atp => atp.Urn = 0) - .With(atp => atp.Id = 0) - .With(atp => atp.TransferringAcademies = Builder - .CreateListOfSize(3) - .All() - .With(ta => ta.Id = 0) - .With(ta => ta.OutgoingAcademyUkprn = randomGenerator.NextString(8, 8)) - .With(ta => ta.IncomingTrustUkprn = incomingTrustGroup.Ukprn) - .With(ta => ta.FkAcademyTransferProjectId = null) - .With(ta => ta.PupilNumbersAdditionalInformation = randomGenerator.NextString(0,1000)) - .With(ta => ta.LatestOfstedReportAdditionalInformation = randomGenerator.NextString(0,1000)) - .With(ta => ta.KeyStage2PerformanceAdditionalInformation = randomGenerator.NextString(0,1000)) - .With(ta => ta.KeyStage4PerformanceAdditionalInformation = randomGenerator.NextString(0,1000)) - .With(ta => ta.KeyStage5PerformanceAdditionalInformation = randomGenerator.NextString(0,1000)) - .Build() - ) - .With(atp => atp.AcademyTransferProjectIntendedTransferBenefits = - Builder - .CreateListOfSize(5) - .All() - .With(benefit => benefit.Id = 0) - .Build() - ) - .Build().ToList(); - - _tramsDbContext.AcademyTransferProjects.AddRange(academyTransferProjectsToCreate); - _tramsDbContext.SaveChanges(); - - var indexAcademyTransferProjectRequest = new HttpRequestMessage - { - Method = HttpMethod.Get, - RequestUri = new Uri($"https://trams-api.com/academyTransferProject/"), - Headers = - { - {"ApiKey", "testing-api-key"} - }, - }; - - var indexResponse = await _client.SendAsync(indexAcademyTransferProjectRequest); - indexResponse.StatusCode.Should().Be(HttpStatusCode.OK); - var indexJson = await indexResponse.Content.ReadAsStringAsync(); - var indexProjectResponse = JsonConvert.DeserializeObject>(indexJson); - indexProjectResponse.Results.Count().Should().Be(numberOfProjectsPerPage); - } - - [Fact] - public async Task ShouldNotReturnProjectsWithEmptyOutgoingTrust() - { - const int numberOfProjects = 5; - var randomGenerator = new RandomGenerator(); - - var groups = AddGroups(2); - var outgoingTrustGroup = groups[0]; - var incomingTrustGroup = groups[1]; - - var academyTransferProjectsToCreate = Builder - .CreateListOfSize(numberOfProjects) - .All() - .With(atp => atp.OutgoingTrustUkprn = outgoingTrustGroup.Ukprn) - .With(atp => atp.Urn = 0) - .With(atp => atp.Id = 0) - .With(atp => atp.TransferringAcademies = Builder - .CreateListOfSize(3) - .All() - .With(ta => ta.Id = 0) - .With(ta => ta.OutgoingAcademyUkprn = randomGenerator.NextString(8, 8)) - .With(ta => ta.IncomingTrustUkprn = incomingTrustGroup.Ukprn) - .With(ta => ta.FkAcademyTransferProjectId = null) - .With(ta => ta.PupilNumbersAdditionalInformation = randomGenerator.NextString(0, 1000)) - .With(ta => ta.LatestOfstedReportAdditionalInformation = randomGenerator.NextString(0, 1000)) - .With(ta => ta.KeyStage2PerformanceAdditionalInformation = randomGenerator.NextString(0, 1000)) - .With(ta => ta.KeyStage4PerformanceAdditionalInformation = randomGenerator.NextString(0, 1000)) - .With(ta => ta.KeyStage5PerformanceAdditionalInformation = randomGenerator.NextString(0, 1000)) - .Build() - ) - .With(atp => atp.AcademyTransferProjectIntendedTransferBenefits = - Builder - .CreateListOfSize(5) - .All() - .With(benefit => benefit.Id = 0) - .Build() - ) - .Build().ToList(); - - academyTransferProjectsToCreate[0].OutgoingTrustUkprn = ""; - - _tramsDbContext.AcademyTransferProjects.AddRange(academyTransferProjectsToCreate); - _tramsDbContext.SaveChanges(); - - var indexAcademyTransferProjectRequest = new HttpRequestMessage - { - Method = HttpMethod.Get, - RequestUri = new Uri($"https://trams-api.com/academyTransferProjects?page=1&count={numberOfProjects}"), - Headers = - { - {"ApiKey", "testing-api-key"} - }, - }; - - var indexResponse = await _client.SendAsync(indexAcademyTransferProjectRequest); - indexResponse.StatusCode.Should().Be(HttpStatusCode.OK); - var indexJson = await indexResponse.Content.ReadAsStringAsync(); - var indexProjectResponse = JsonConvert.DeserializeObject>(indexJson); - - indexProjectResponse.Results.Count().Should().Be(numberOfProjects - 1); - Assert.DoesNotContain(indexProjectResponse.Results, p => p.ProjectUrn == academyTransferProjectsToCreate[0].Urn.ToString()); - } - - [Fact] - public async Task ShouldNotReturnProjectsWithEmptyIncomingTrust() - { - const int numberOfProjects = 5; - var randomGenerator = new RandomGenerator(); - - var groups = AddGroups(2); - var outgoingTrustGroup = groups[0]; - var incomingTrustGroup = groups[1]; - - var academyTransferProjectsToCreate = Builder - .CreateListOfSize(numberOfProjects) - .All() - .With(atp => atp.OutgoingTrustUkprn = outgoingTrustGroup.Ukprn) - .With(atp => atp.Urn = 0) - .With(atp => atp.Id = 0) - .With(atp => atp.TransferringAcademies = Builder - .CreateListOfSize(3) - .All() - .With(ta => ta.Id = 0) - .With(ta => ta.OutgoingAcademyUkprn = randomGenerator.NextString(8, 8)) - .With(ta => ta.IncomingTrustUkprn = incomingTrustGroup.Ukprn) - .With(ta => ta.FkAcademyTransferProjectId = null) - .With(ta => ta.PupilNumbersAdditionalInformation = randomGenerator.NextString(0, 1000)) - .With(ta => ta.LatestOfstedReportAdditionalInformation = randomGenerator.NextString(0, 1000)) - .With(ta => ta.KeyStage2PerformanceAdditionalInformation = randomGenerator.NextString(0, 1000)) - .With(ta => ta.KeyStage4PerformanceAdditionalInformation = randomGenerator.NextString(0, 1000)) - .With(ta => ta.KeyStage5PerformanceAdditionalInformation = randomGenerator.NextString(0, 1000)) - .Build() - ) - .With(atp => atp.AcademyTransferProjectIntendedTransferBenefits = - Builder - .CreateListOfSize(5) - .All() - .With(benefit => benefit.Id = 0) - .Build() - ) - .Build().ToList(); - - academyTransferProjectsToCreate[0].TransferringAcademies.First().IncomingTrustUkprn = ""; - - _tramsDbContext.AcademyTransferProjects.AddRange(academyTransferProjectsToCreate); - _tramsDbContext.SaveChanges(); - - var indexAcademyTransferProjectRequest = new HttpRequestMessage - { - Method = HttpMethod.Get, - RequestUri = new Uri($"https://trams-api.com/academyTransferProjects?page=1&count={numberOfProjects}"), - Headers = - { - {"ApiKey", "testing-api-key"} - }, - }; - - var indexResponse = await _client.SendAsync(indexAcademyTransferProjectRequest); - indexResponse.StatusCode.Should().Be(HttpStatusCode.OK); - var indexJson = await indexResponse.Content.ReadAsStringAsync(); - var indexProjectResponse = JsonConvert.DeserializeObject>(indexJson); - - indexProjectResponse.Results.Count().Should().Be(numberOfProjects - 1); - Assert.DoesNotContain(indexProjectResponse.Results, p => p.ProjectUrn == academyTransferProjectsToCreate[0].Urn.ToString()); - } - - [Fact] - public async Task CanGetTheSecondPageOfAllAcademyTransferProjects() - { - const int numberOfProjects = 20; - const int pageNumberRequested = 2; - - var randomGenerator = new RandomGenerator(); - - var groups = AddGroups(2); - var outgoingTrustGroup = groups[0]; - var incomingTrustGroup = groups[1]; - var trusts = AddTrustsFromGroups(groups); - - var academyTransferProjectsToCreate = Builder - .CreateListOfSize(numberOfProjects) - .All() - .With(atp => atp.OutgoingTrustUkprn = outgoingTrustGroup.Ukprn) - .With(atp => atp.Urn = 0) - .With(atp => atp.Id = 0) - .With(atp => atp.TransferringAcademies = Builder - .CreateListOfSize(3) - .All() - .With(ta => ta.Id = 0) - .With(ta => ta.OutgoingAcademyUkprn = randomGenerator.NextString(8, 8)) - .With(ta => ta.IncomingTrustUkprn = incomingTrustGroup.Ukprn) - .With(ta => ta.FkAcademyTransferProjectId = null) - .With(ta => ta.PupilNumbersAdditionalInformation = randomGenerator.NextString(0,1000)) - .With(ta => ta.LatestOfstedReportAdditionalInformation = randomGenerator.NextString(0,1000)) - .With(ta => ta.KeyStage2PerformanceAdditionalInformation = randomGenerator.NextString(0,1000)) - .With(ta => ta.KeyStage4PerformanceAdditionalInformation = randomGenerator.NextString(0,1000)) - .With(ta => ta.KeyStage5PerformanceAdditionalInformation = randomGenerator.NextString(0,1000)) - .Build() - ) - .With(atp => atp.AcademyTransferProjectIntendedTransferBenefits = - Builder - .CreateListOfSize(5) - .All() - .With(benefit => benefit.Id = 0) - .Build() - ) - .Build().ToList(); - - _tramsDbContext.AcademyTransferProjects.AddRange(academyTransferProjectsToCreate); - _tramsDbContext.SaveChanges(); - - - var indexAcademyTransferProjectRequest = new HttpRequestMessage - { - Method = HttpMethod.Get, - RequestUri = new Uri($"https://trams-api.com/academyTransferProject?page={pageNumberRequested}"), - Headers = - { - {"ApiKey", "testing-api-key"} - }, - }; - - var indexResponse = await _client.SendAsync(indexAcademyTransferProjectRequest); - var indexJson = await indexResponse.Content.ReadAsStringAsync(); - var indexProjectResponse = JsonConvert.DeserializeObject>(indexJson); - - indexResponse.StatusCode.Should().Be(HttpStatusCode.OK); - indexProjectResponse.Results.Count().Should().Be(numberOfProjectsPerPage); - } - - - [Fact] - public async Task ReturnsEmptyListWhenPageTooHigh() - { - var randomGenerator = new RandomGenerator(); - var academyTransferProjectsToCreate = Builder - .CreateListOfSize(20) - .All() - .With(atp => atp.OutgoingTrustUkprn = randomGenerator.NextString(8, 8)) - .With(atp => atp.Urn = 0) - .With(atp => atp.Id = 0) - .With(atp => atp.TransferringAcademies = Builder - .CreateListOfSize(3) - .All() - .With(ta => ta.Id = 0) - .With(ta => ta.OutgoingAcademyUkprn = randomGenerator.NextString(8, 8)) - .With(ta => ta.IncomingTrustUkprn = randomGenerator.NextString(8, 8)) - .With(ta => ta.FkAcademyTransferProjectId = null) - .Build() - ) - .With(atp => atp.AcademyTransferProjectIntendedTransferBenefits = - Builder - .CreateListOfSize(5) - .All() - .With(benefit => benefit.Id = 0) - .Build() - ) - .Build().ToList(); - - _tramsDbContext.AcademyTransferProjects.AddRange(academyTransferProjectsToCreate); - _tramsDbContext.SaveChanges(); - - var indexAcademyTransferProjectRequest = new HttpRequestMessage - { - Method = HttpMethod.Get, - RequestUri = new Uri($"https://trams-api.com/academyTransferProject?page=4"), - Headers = - { - {"ApiKey", "testing-api-key"} - }, - }; - - var indexResponse = await _client.SendAsync(indexAcademyTransferProjectRequest); - indexResponse.StatusCode.Should().Be(HttpStatusCode.OK); - var indexJson = await indexResponse.Content.ReadAsStringAsync(); - var indexProjectResponse = - JsonConvert.DeserializeObject>(indexJson); - - indexProjectResponse.Results.Count().Should().Be(0); - indexProjectResponse.Results.Should().BeEquivalentTo(Enumerable.Empty()); - } - - [Fact] - public async Task Returns404WhenAcademyTransferProjectDoesNotExist() - { - var getAcademyTransferProjectRequest = new HttpRequestMessage - { - Method = HttpMethod.Get, - RequestUri = new Uri($"https://trams-api.com/academyTransferProject/10012313"), - Headers = - { - {"ApiKey", "testing-api-key"} - }, - }; - - var getResponse = await _client.SendAsync(getAcademyTransferProjectRequest); - getResponse.StatusCode.Should().Be(HttpStatusCode.NotFound); - } - - [Fact] - public async Task CanGetAnAcademyTransferProject() - { - var randomGenerator = new RandomGenerator(); - - var academyTransferProject = Builder - .CreateNew() - .With(atp => atp.OutgoingTrustUkprn = randomGenerator.NextString(8, 8)) - .With(atp => atp.Urn = 0) - .With(atp => atp.Id = 0) - .With(atp => atp.TransferringAcademies = Builder - .CreateListOfSize(3) - .All() - .With(ta => ta.Id = 0) - .With(ta => ta.OutgoingAcademyUkprn = randomGenerator.NextString(8, 8)) - .With(ta => ta.IncomingTrustUkprn = randomGenerator.NextString(8, 8)) - .With(ta => ta.FkAcademyTransferProjectId = null) - .Build() - ) - .With(atp => atp.AcademyTransferProjectIntendedTransferBenefits = - Builder - .CreateListOfSize(5) - .All() - .With(benefit => benefit.Id = 0) - .Build() - ) - .Build(); - - _tramsDbContext.AcademyTransferProjects.Add(academyTransferProject); - _tramsDbContext.SaveChanges(); - - var getAcademyTransferProjectRequest = new HttpRequestMessage - { - Method = HttpMethod.Get, - RequestUri = new Uri($"https://trams-api.com/academyTransferProject/{academyTransferProject.Urn}"), - Headers = - { - {"ApiKey", "testing-api-key"} - }, - }; - - var getResponse = await _client.SendAsync(getAcademyTransferProjectRequest); - getResponse.StatusCode.Should().Be(HttpStatusCode.OK); - - var responseJson = await getResponse.Content.ReadAsStringAsync(); - var responseModel = JsonConvert.DeserializeObject(responseJson); - - var expected = AcademyTransferProjectResponseFactory.Create(academyTransferProject); - - responseModel.Should().BeEquivalentTo(expected); - } - - private IList AddGroups(int numberOfGroups) - { - var randomGenerator = new RandomGenerator(); - var groups = Builder.CreateListOfSize(numberOfGroups) - .All() - .With(g => g.Ukprn = randomGenerator.NextString(8, 8)) - .With(g => g.GroupId = randomGenerator.NextString(7, 7)) - .With(g => g.GroupName = randomGenerator.NextString(8, 8)) - .With(g => g.GroupUid = randomGenerator.Int().ToString()) - .Build(); - - _legacyTramsDbContext.Group.AddRange(groups); - _legacyTramsDbContext.SaveChanges(); - - return groups; - } - - private IList AddTrustsFromGroups(IList groups) - { - var randomGenerator = new RandomGenerator(); - var trusts = groups.Select((group, index) => new Trust { Rid = index.ToString(), TrustRef = group.GroupId }).ToList(); - AddTrusts(trusts); - return trusts; - } - - private void AddTrusts(IList trusts) - { - _legacyTramsDbContext.Trust.AddRange(trusts); - _legacyTramsDbContext.SaveChanges(); - } - - public void Dispose() - { - _tramsDbContext.TransferringAcademies.RemoveRange(_tramsDbContext.TransferringAcademies); - _tramsDbContext.AcademyTransferProjectIntendedTransferBenefits - .RemoveRange(_tramsDbContext.AcademyTransferProjectIntendedTransferBenefits); - _tramsDbContext.AcademyTransferProjects.RemoveRange(_tramsDbContext.AcademyTransferProjects); - _tramsDbContext.SaveChanges(); - - _legacyTramsDbContext.Group.RemoveRange(_legacyTramsDbContext.Group); - _legacyTramsDbContext.Trust.RemoveRange(_legacyTramsDbContext.Trust); - _legacyTramsDbContext.SaveChanges(); - } - } -} diff --git a/TramsDataApi.Test/UseCases/CreateAcademyTransferProjectTests.cs b/TramsDataApi.Test/UseCases/CreateAcademyTransferProjectTests.cs deleted file mode 100644 index ab703251..00000000 --- a/TramsDataApi.Test/UseCases/CreateAcademyTransferProjectTests.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using FizzWare.NBuilder; -using FluentAssertions; -using Moq; -using TramsDataApi.DatabaseModels; -using TramsDataApi.Factories; -using TramsDataApi.Gateways; -using TramsDataApi.RequestModels; -using TramsDataApi.RequestModels.AcademyTransferProject; -using TramsDataApi.UseCases; -using Xunit; - -namespace TramsDataApi.Test.UseCases -{ - public class CreateAcademyTransferProjectTests - { - [Fact] - public void ShouldCreateAndReturnAnAcademyTransferProject_WhenGivenACreateOrUpdateAcademyTransferProjectRequest() - { - var randomGenerator = new RandomGenerator(); - - var gateway = new Mock(); - var benefitsRequest = Builder.CreateNew() - .With(b => b.IntendedTransferBenefits = Builder.CreateNew() - .With(i => i.SelectedBenefits = new List()).Build()) - .With(b => b.OtherFactorsToConsider = Builder.CreateNew() - .With(o => o.ComplexLandAndBuilding = Builder.CreateNew().Build()) - .With(o => o.FinanceAndDebt = Builder.CreateNew().Build()) - .With(o => o.HighProfile = Builder.CreateNew().Build()).Build()) - .Build(); - - var datesRequest = Builder.CreateNew() - .With(d => d.TransferFirstDiscussed = - randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)) - .With(d => d.TargetDateForTransfer = - randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)) - .With(d => d.HtbDate = randomGenerator.DateTime().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)) - .Build(); - - var createRequest = Builder.CreateNew() - .With(c => c.Benefits = benefitsRequest) - .With(c => c.Dates = datesRequest) - .With(c => c.Rationale = Builder.CreateNew().Build()) - .With(c => c.GeneralInformation = Builder.CreateNew().Build()) - .With(c => c.Features = Builder.CreateNew().Build()) - .With(c => c.TransferringAcademies = (List) Builder - .CreateListOfSize(5).Build()) - .Build(); - - var convertedAcademyTransferProject = AcademyTransferProjectFactory.Create(createRequest); - var createdAcademyTransferProject = AcademyTransferProjectFactory.Create(createRequest); - createdAcademyTransferProject.Urn = randomGenerator.Int(); - - var expected = AcademyTransferProjectResponseFactory.Create(createdAcademyTransferProject); - - gateway.Setup(g => g.SaveAcademyTransferProject(It.IsAny())).Returns(createdAcademyTransferProject); - - - var useCase = new CreateAcademyTransferProject(gateway.Object); - var result = useCase.Execute(createRequest); - - result.Should().BeEquivalentTo(expected); - } - } -} \ No newline at end of file diff --git a/TramsDataApi.Test/UseCases/GetAcademyTransferProjectTests.cs b/TramsDataApi.Test/UseCases/GetAcademyTransferProjectTests.cs deleted file mode 100644 index 8510f783..00000000 --- a/TramsDataApi.Test/UseCases/GetAcademyTransferProjectTests.cs +++ /dev/null @@ -1,48 +0,0 @@ -using FizzWare.NBuilder; -using FluentAssertions; -using Moq; -using TramsDataApi.DatabaseModels; -using TramsDataApi.Factories; -using TramsDataApi.Gateways; -using TramsDataApi.UseCases; -using Xunit; - -namespace TramsDataApi.Test.UseCases -{ - public class GetAcademyTransferProjectTests - { - [Fact] - public void GetAcademyTransferProjectByUrn_ReturnsNull_WhenAcademyTransferProjectIsNotFound() - { - var urn = 10010010; - var academyTransferProjectsGateway = new Mock(); - - academyTransferProjectsGateway.Setup(atGateway => atGateway.GetAcademyTransferProjectByUrn(urn)) - .Returns(() => null); - - - var useCase = new GetAcademyTransferProject(academyTransferProjectsGateway.Object); - var result = useCase.Execute(urn); - - result.Should().BeNull(); - } - - [Fact] - public void GetAcademyTransferProjectByUrn_ReturnsAnAcademyTransferProjectResponse_WhenTheProjectIsFound() - { - var urn = 10010010; - var academyTransferProjectsGateway = new Mock(); - var academyTransferProject = Builder.CreateNew().Build(); - var expected = AcademyTransferProjectResponseFactory.Create(academyTransferProject); - - academyTransferProjectsGateway.Setup(atGateway => atGateway.GetAcademyTransferProjectByUrn(urn)) - .Returns(academyTransferProject); - - - var useCase = new GetAcademyTransferProject(academyTransferProjectsGateway.Object); - var result = useCase.Execute(urn); - - result.Should().BeEquivalentTo(expected); - } - } -} \ No newline at end of file diff --git a/TramsDataApi.Test/UseCases/IndexAcademyTransferProjectTests.cs b/TramsDataApi.Test/UseCases/IndexAcademyTransferProjectTests.cs deleted file mode 100644 index 819e09d1..00000000 --- a/TramsDataApi.Test/UseCases/IndexAcademyTransferProjectTests.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using Moq; -using TramsDataApi.DatabaseModels; -using TramsDataApi.Gateways; -using TramsDataApi.ResponseModels; -using TramsDataApi.ResponseModels.AcademyTransferProject; -using TramsDataApi.UseCases; -using Xunit; - -namespace TramsDataApi.Test.UseCases -{ - public class IndexAcademyTransferProjectTests - { - [Fact] - public void GetIndex_ReturnsAListOfAcademyTransferProjectSummaryResponses_WhenThereAreAcademyTransferProjects() - { - var outgoingTrust = "outgoingTrust"; - var incomingTrust = "incomingTrust"; - var expectedAcademyTransferProjects = Builder.CreateListOfSize(5).All() - .With(p => p.OutgoingTrustUkprn = outgoingTrust) - .With(p => p.TransferringAcademies = Builder.CreateListOfSize(5).All() - .With(a => a.IncomingTrustUkprn = incomingTrust) - .With(a => a.PupilNumbersAdditionalInformation = "pupil numbers") - .With(a => a.LatestOfstedReportAdditionalInformation = "ofsted") - .With(a => a.KeyStage2PerformanceAdditionalInformation = "ks2") - .With(a => a.KeyStage4PerformanceAdditionalInformation = "ks4") - .With(a => a.KeyStage5PerformanceAdditionalInformation = "ks5") - .Build()) - .Build(); - - var expectedOutgoingGroup = Builder.CreateNew().Build(); - var expectedOutgoingTrust = Builder.CreateNew().Build(); - var expectedIncomingGroup = Builder.CreateNew().Build(); - var expectedIncomingTrust = Builder.CreateNew().Build(); - - var academyTransferProjectsGateway = new Mock(); - - academyTransferProjectsGateway.Setup(atGateway => atGateway.IndexAcademyTransferProjects(1)) - .Returns(() => Tuple.Create(expectedAcademyTransferProjects, expectedAcademyTransferProjects.Count)); - - var trustGateway = new Mock(); - trustGateway.Setup(tg => tg.GetGroupByUkPrn(outgoingTrust)).Returns(expectedOutgoingGroup); - trustGateway.Setup(tg => tg.GetGroupByUkPrn(incomingTrust)).Returns(expectedIncomingGroup); - trustGateway.Setup(tg => tg.GetIfdTrustByGroupId(expectedOutgoingGroup.GroupId)) - .Returns(expectedOutgoingTrust); - trustGateway.Setup(tg => tg.GetIfdTrustByGroupId(expectedIncomingGroup.GroupId)) - .Returns(expectedIncomingTrust); - - var expectedIndexResponse = expectedAcademyTransferProjects - .Select(atp => new AcademyTransferProjectSummaryResponse - { - ProjectUrn = atp.Urn.ToString(), - ProjectReference = atp.ProjectReference, - OutgoingTrustUkprn = atp.OutgoingTrustUkprn, - OutgoingTrustName = expectedOutgoingGroup.GroupName, - OutgoingTrustLeadRscRegion = expectedOutgoingTrust.LeadRscRegion, - TransferringAcademies = atp.TransferringAcademies.Select(ta => new TransferringAcademiesResponse - { - OutgoingAcademyUkprn = ta.OutgoingAcademyUkprn, - IncomingTrustUkprn = ta.IncomingTrustUkprn, - IncomingTrustName = expectedIncomingGroup.GroupName, - IncomingTrustLeadRscRegion = expectedIncomingTrust.LeadRscRegion, - PupilNumbersAdditionalInformation = ta.PupilNumbersAdditionalInformation, - LatestOfstedReportAdditionalInformation = ta.LatestOfstedReportAdditionalInformation, - KeyStage2PerformanceAdditionalInformation = ta.KeyStage2PerformanceAdditionalInformation, - KeyStage4PerformanceAdditionalInformation = ta.KeyStage4PerformanceAdditionalInformation, - KeyStage5PerformanceAdditionalInformation = ta.KeyStage5PerformanceAdditionalInformation - }).ToList() - }).ToList(); - - - var useCase = new IndexAcademyTransferProjects(academyTransferProjectsGateway.Object, trustGateway.Object); - var result = useCase.Execute(1); - - result.Item1.Count.Should().Be(5); - result.Item2.Should().Be(5); - result.Item1.Should().BeEquivalentTo(expectedIndexResponse); - } - } -} \ No newline at end of file diff --git a/TramsDataApi.Test/UseCases/SearchAcademyTransferProjectsTests.cs b/TramsDataApi.Test/UseCases/SearchAcademyTransferProjectsTests.cs deleted file mode 100644 index b7890d02..00000000 --- a/TramsDataApi.Test/UseCases/SearchAcademyTransferProjectsTests.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using Moq; -using TramsDataApi.DatabaseModels; -using TramsDataApi.Gateways; -using TramsDataApi.RequestModels; -using TramsDataApi.ResponseModels; -using TramsDataApi.ResponseModels.AcademyTransferProject; -using TramsDataApi.UseCases; -using Xunit; - -namespace TramsDataApi.Test.UseCases -{ - public class SearchAcademyTransferProjectsTests - { - private const int Outgoing = 0, Incoming = 1; - - [Fact] - public void - Search_ReturnsAListOfAcademyTransferProjectSummaryResponses_WhenThereAreAcademyTransferProjects_ByTitle() - { - IList trusts = Builder.CreateListOfSize(2).Build(); - IList groups = Builder.CreateListOfSize(2).Build(); - trusts[Outgoing].TrustRef = groups[Outgoing].GroupId; - trusts[Incoming].TrustRef = groups[Incoming].GroupId; - - var academyTransferProjectsGateway = new Mock(); - var trustGateway = new Mock(); - - IList expectedAcademyTransferProjects = Builder - .CreateListOfSize(5).All() - .With(p => p.OutgoingTrustUkprn = groups[Outgoing].Ukprn) - .With(p => p.TransferringAcademies = Builder.CreateListOfSize(3).All() - .With(a => a.IncomingTrustUkprn = groups[Outgoing].Ukprn) - .With(a => a.PupilNumbersAdditionalInformation = "pupil numbers") - .With(a => a.LatestOfstedReportAdditionalInformation = "ofsted") - .With(a => a.KeyStage2PerformanceAdditionalInformation = "ks2") - .With(a => a.KeyStage4PerformanceAdditionalInformation = "ks4") - .With(a => a.KeyStage5PerformanceAdditionalInformation = "ks5") - .Build()) - .Build(); - - expectedAcademyTransferProjects[1].TransferringAcademies.Skip(1).Take(1).First().IncomingTrustUkprn = - groups[Incoming].Ukprn; - - academyTransferProjectsGateway.Setup(atGateway => atGateway.GetAcademyTransferProjects()) - .Returns(() => expectedAcademyTransferProjects); - - trustGateway.Setup(x => x.GetMultipleTrustsByGroupId(It.IsAny>())) - .Returns(trusts); - trustGateway.Setup(x => x.GetMultipleGroupsByUkprn(It.IsAny>())) - .Returns(groups); - - var expectedIndexResponse = new List - { - new AcademyTransferProjectSummaryResponse - { - ProjectUrn = expectedAcademyTransferProjects[1].Urn.ToString(), - ProjectReference = expectedAcademyTransferProjects[1].ProjectReference, - OutgoingTrustUkprn = expectedAcademyTransferProjects[1].OutgoingTrustUkprn, - OutgoingTrustName = groups[Outgoing].GroupName, - OutgoingTrustLeadRscRegion = trusts[Outgoing].LeadRscRegion, - AssignedUser = new AssignedUserResponse - { - EmailAddress = expectedAcademyTransferProjects[1].AssignedUserEmailAddress, - FullName = expectedAcademyTransferProjects[1].AssignedUserFullName, - Id = expectedAcademyTransferProjects[1].AssignedUserId - }, - TransferringAcademies = expectedAcademyTransferProjects[1].TransferringAcademies.Select(ta => - { - Group group = groups.First(g => g.Ukprn == ta.IncomingTrustUkprn); - return new TransferringAcademiesResponse - { - OutgoingAcademyUkprn = ta.OutgoingAcademyUkprn, - IncomingTrustUkprn = ta.IncomingTrustUkprn, - IncomingTrustName = group.GroupName, - IncomingTrustLeadRscRegion = trusts.First(x => x.TrustRef == group.GroupId).LeadRscRegion, - PupilNumbersAdditionalInformation = ta.PupilNumbersAdditionalInformation, - LatestOfstedReportAdditionalInformation = ta.LatestOfstedReportAdditionalInformation, - KeyStage2PerformanceAdditionalInformation = ta.KeyStage2PerformanceAdditionalInformation, - KeyStage4PerformanceAdditionalInformation = ta.KeyStage4PerformanceAdditionalInformation, - KeyStage5PerformanceAdditionalInformation = ta.KeyStage5PerformanceAdditionalInformation - }; - }).ToList() - } - }; - - var searchCriteria = groups[Incoming].GroupName; - - var useCase = new SearchAcademyTransferProjects(academyTransferProjectsGateway.Object, trustGateway.Object); - - PagedResult searchResult = - useCase.Execute(1, 50, default, searchCriteria).Result; - - searchResult.Results.Should().NotBeEmpty(); - searchResult.Results.Count().Should().Be(1); - searchResult.TotalCount.Should().Be(1); - searchResult.Results.Should().BeEquivalentTo(expectedIndexResponse); - } - } -} diff --git a/TramsDataApi.Test/UseCases/UpdateAcademyTransferProjectTests.cs b/TramsDataApi.Test/UseCases/UpdateAcademyTransferProjectTests.cs deleted file mode 100644 index 72911e95..00000000 --- a/TramsDataApi.Test/UseCases/UpdateAcademyTransferProjectTests.cs +++ /dev/null @@ -1,53 +0,0 @@ -using FizzWare.NBuilder; -using FluentAssertions; -using Moq; -using TramsDataApi.DatabaseModels; -using TramsDataApi.Gateways; -using TramsDataApi.RequestModels; -using System.Globalization; -using Xunit; -using System; -using TramsDataApi.UseCases; -using TramsDataApi.Factories; -using TramsDataApi.RequestModels.AcademyTransferProject; - -namespace TramsDataApi.Test.UseCases -{ - public class UpdateAcademyTransferProjectTests - { - [Fact] - public void ShouldSaveAnUpdateAcademyTransferProject_WhenGivenAPartialModelToUpdate() - { - var urn = 10010010; - var gateway = new Mock(); - var academyTransferProject = Builder - .CreateNew().With(atp => atp.Urn = urn).Build(); - var updateAcademyTransferProject = new AcademyTransferProjectRequest - { - OutgoingTrustUkprn = "12345123", - Dates = new AcademyTransferProjectDatesRequest - { - TargetDateForTransfer = "12/12/2022" - }, - Features = new AcademyTransferProjectFeaturesRequest - { - WhoInitiatedTheTransfer = "Somebody Else" - } - }; - - gateway.Setup(g => g.GetAcademyTransferProjectByUrn(urn)).Returns(academyTransferProject); - - var expectedUpdatedProject = AcademyTransferProjectFactory.Update(academyTransferProject, updateAcademyTransferProject); - - gateway.Setup(g => g.UpdateAcademyTransferProject( - It.Is(atp => atp.Id == academyTransferProject.Id && atp.OutgoingTrustUkprn == updateAcademyTransferProject.OutgoingTrustUkprn)) - ).Returns(expectedUpdatedProject); - - var expected = AcademyTransferProjectResponseFactory.Create(expectedUpdatedProject); - var useCase = new UpdateAcademyTransferProject(gateway.Object); - var result = useCase.Execute(urn, updateAcademyTransferProject); - - result.Should().BeEquivalentTo(expected); - } - } -} \ No newline at end of file diff --git a/TramsDataApi.Test/Validators/AcademyTransferProjectRequestValidatorTests.cs b/TramsDataApi.Test/Validators/AcademyTransferProjectRequestValidatorTests.cs deleted file mode 100644 index e4fe3266..00000000 --- a/TramsDataApi.Test/Validators/AcademyTransferProjectRequestValidatorTests.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Linq; -using FizzWare.NBuilder; -using FluentValidation.TestHelper; -using TramsDataApi.RequestModels.AcademyTransferProject; -using TramsDataApi.Validators; -using Xunit; - -namespace TramsDataApi.Test.Validators -{ - public class AcademyTransferProjectRequestValidatorTests - { - [Fact] - public void ShouldHaveError_WhenOutgoingUkprnIsNull() - { - var validator = new AcademyTransferProjectRequestValidator(); - var request = Builder.CreateNew() - .With(atp => atp.OutgoingTrustUkprn = null) - .Build(); - - var result = validator.TestValidate(request); - result.ShouldHaveValidationErrorFor(atp => atp.OutgoingTrustUkprn) - .WithErrorCode("NotNullValidator"); - } - - [Fact] - public void ShouldHaveError_WhenOutgoingUkprnIsNot8CharactersLong() - { - var validator = new AcademyTransferProjectRequestValidator(); - var request = Builder.CreateNew() - .With(atp => atp.OutgoingTrustUkprn = "0000") - .Build(); - - var result = validator.TestValidate(request); - result.ShouldHaveValidationErrorFor(atp => atp.OutgoingTrustUkprn) - .WithErrorCode("ExactLengthValidator");; - } - } -} \ No newline at end of file diff --git a/TramsDataApi.Test/Validators/TransferringAcademiesRequestValidatorTests.cs b/TramsDataApi.Test/Validators/TransferringAcademiesRequestValidatorTests.cs deleted file mode 100644 index 32f38872..00000000 --- a/TramsDataApi.Test/Validators/TransferringAcademiesRequestValidatorTests.cs +++ /dev/null @@ -1,38 +0,0 @@ -using FizzWare.NBuilder; -using FluentValidation.TestHelper; -using TramsDataApi.RequestModels; -using TramsDataApi.Validators; -using Xunit; - -namespace TramsDataApi.Test.Validators -{ - public class TransferringAcademiesRequestValidatorTests - { - [Fact] - public void ShouldHaveError_WhenOutgoingAcademyUkprnIsNull() - { - var validator = new TransferringAcademiesRequestValidator(); - - var request = Builder.CreateNew() - .With(atp => atp.OutgoingAcademyUkprn = null) - .Build(); - - var result = validator.TestValidate(request); - result.ShouldHaveValidationErrorFor(ta => ta.OutgoingAcademyUkprn) - .WithErrorCode("NotNullValidator"); - } - - [Fact] - public void ShouldHaveError_WhenOutgoingAcademyUkprnIsNot8CharactersLong() - { - var validator = new TransferringAcademiesRequestValidator(); - var request = Builder.CreateNew() - .With(atp => atp.OutgoingAcademyUkprn = "1102") - .Build(); - - var result = validator.TestValidate(request); - result.ShouldHaveValidationErrorFor(atp => atp.OutgoingAcademyUkprn) - .WithErrorCode("ExactLengthValidator");; - } - } -} \ No newline at end of file diff --git a/TramsDataApi/Controllers/AcademyTransferProjectController.cs b/TramsDataApi/Controllers/AcademyTransferProjectController.cs deleted file mode 100644 index 56de6464..00000000 --- a/TramsDataApi/Controllers/AcademyTransferProjectController.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using TramsDataApi.DatabaseModels; -using TramsDataApi.RequestModels; -using TramsDataApi.RequestModels.AcademyTransferProject; -using TramsDataApi.ResponseModels.AcademyTransferProject; -using TramsDataApi.UseCases; -using TramsDataApi.Validators; - -namespace TramsDataApi.Controllers -{ - [ApiController] - [ApiVersion("1.0")] - - public class AcademyTransferProjectController : ControllerBase - { - private const string SearchProjectsLog = - "Attempting to retrieve {Count} Academy Transfer Projects filtered by: urn: {Urn} title: {Title}"; - private const string ReturnProjectsLog = "Returning {count} Academy Transfer Projects with Id(s): {ids}"; - private readonly ICreateAcademyTransferProject _createAcademyTransferProject; - private readonly ISearchAcademyTransferProjects _searchAcademyTransferProject; - private readonly IGetAcademyTransferProject _getAcademyTransferProject; - private readonly IUpdateAcademyTransferProject _updateAcademyTransferProject; - private readonly IIndexAcademyTransferProjects _indexAcademyTransferProject; - private readonly ILogger _logger; - - - public AcademyTransferProjectController( - ICreateAcademyTransferProject createAcademyTransferProject, - ISearchAcademyTransferProjects searchAcademyTransferProject, - IGetAcademyTransferProject getAcademyTransferProject, - IUpdateAcademyTransferProject updateAcademyTransferProject, - IIndexAcademyTransferProjects indexAcademyTransferProjects, - ILogger logger) - { - _createAcademyTransferProject = createAcademyTransferProject; - _searchAcademyTransferProject = searchAcademyTransferProject; - _getAcademyTransferProject = getAcademyTransferProject; - _updateAcademyTransferProject = updateAcademyTransferProject; - _indexAcademyTransferProject = indexAcademyTransferProjects; - _logger = logger; - } - - [HttpPost] - [Route("academyTransferProject")] - public ActionResult Create(AcademyTransferProjectRequest request) - { - _logger.LogInformation($"Attempting to create Academy Transfer Project"); - var validator = new AcademyTransferProjectRequestValidator(); - if (validator.Validate(request).IsValid) - { - var createdAcademyTransferProject = _createAcademyTransferProject.Execute(request); - _logger.LogInformation($"Successfully created new Academy Transfer Project with URN {createdAcademyTransferProject.ProjectUrn}"); - _logger.LogDebug(JsonSerializer.Serialize(createdAcademyTransferProject)); - return CreatedAtAction("Create", createdAcademyTransferProject); - } - _logger.LogInformation($"Failed to create Academy Transfer Project due to bad request"); - return BadRequest(); - } - - [HttpPatch] - [Route("academyTransferProject/{urn}")] - public ActionResult Update(int urn, AcademyTransferProjectRequest request) - { - _logger.LogInformation($"Attempting to update Academy Transfer Project {urn}"); - if (_getAcademyTransferProject.Execute(urn) == null) - { - _logger.LogInformation($"Failed to update: No Academy Transfer Project found for URN {urn}"); - return NotFound(); - } - - var validator = new AcademyTransferProjectRequestValidator(); - if (validator.Validate(request).IsValid) - { - var updatedAcademyTransferProject = _updateAcademyTransferProject.Execute(urn, request); - _logger.LogInformation($"Successfully updated Academy Transfer Project {urn}"); - _logger.LogDebug(JsonSerializer.Serialize(updatedAcademyTransferProject)); - return Ok(updatedAcademyTransferProject); - } - _logger.LogInformation($"Failed to update Academy Transfer Project due to bad request"); - return BadRequest(); - } - - [HttpGet] - [Route("academyTransferProject/{urn}")] - public ActionResult GetByUrn(int urn) - { - _logger.LogInformation($"Attempting to get Academy Transfer Project by URN {urn}"); - var academyTransferProject = _getAcademyTransferProject.Execute(urn); - if (academyTransferProject == null) - { - _logger.LogInformation($"No Academy Transfer Project found for urn {urn}"); - return NotFound(); - } - - _logger.LogInformation($"Returning Academy Transfer Project with URN {urn}"); - _logger.LogDebug(JsonSerializer.Serialize(academyTransferProject)); - return Ok(academyTransferProject); - } - - [HttpGet] - [Route("academyTransferProject")] - public ActionResult> Index([FromQuery(Name="page")]int page = 1) - { - _logger.LogInformation($"Indexing Academy Transfer Projects from page {page}"); - Tuple, int> projects = _indexAcademyTransferProject.Execute(page); - _logger.LogDebug(JsonSerializer.Serialize(projects)); - return Ok(new PagedResult(projects.Item1, projects.Item2)); - } - - [HttpGet] - [Route("academyTransferProjects")] - public async Task> GetTransferProjects( - [FromQuery] string title, - [FromQuery] int page = 1, - [FromQuery] int count = 50, - [FromQuery] int? urn = null) - { - _logger.LogInformation(SearchProjectsLog, count, urn, title); - - PagedResult result = - await _searchAcademyTransferProject.Execute(page, count, urn, title); - - if (result.Results.Any()) - { - IEnumerable projectIds = result.Results.Select(p => p.ProjectUrn); - _logger.LogInformation(ReturnProjectsLog, result.Results.Count(), string.Join(',', projectIds)); - } - - return Ok(result); - } - } -} \ No newline at end of file diff --git a/TramsDataApi/DatabaseModels/AcademyTransferProjectIntendedTransferBenefits.cs b/TramsDataApi/DatabaseModels/AcademyTransferProjectIntendedTransferBenefits.cs deleted file mode 100644 index a72b2c1b..00000000 --- a/TramsDataApi/DatabaseModels/AcademyTransferProjectIntendedTransferBenefits.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; - -// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled. -// If you have enabled NRTs for your project, then un-comment the following line: -// #nullable disable - -namespace TramsDataApi.DatabaseModels -{ - public partial class AcademyTransferProjectIntendedTransferBenefits - { - public int Id { get; set; } - public int? FkAcademyTransferProjectId { get; set; } - public string SelectedBenefit { get; set; } - - public virtual AcademyTransferProjects FkAcademyTransferProject { get; set; } - } -} diff --git a/TramsDataApi/DatabaseModels/AcademyTransferProjects.cs b/TramsDataApi/DatabaseModels/AcademyTransferProjects.cs deleted file mode 100644 index 27c274f6..00000000 --- a/TramsDataApi/DatabaseModels/AcademyTransferProjects.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; - -// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled. -// If you have enabled NRTs for your project, then un-comment the following line: -// #nullable disable - -namespace TramsDataApi.DatabaseModels -{ - public partial class AcademyTransferProjects - { - public AcademyTransferProjects() - { - AcademyTransferProjectIntendedTransferBenefits = - new HashSet(); - TransferringAcademies = new HashSet(); - } - - public int Id { get; set; } - public int Urn { get; set; } - - public string ProjectReference { get; set; } - public string OutgoingTrustUkprn { get; set; } - public string WhoInitiatedTheTransfer { get; set; } - public bool? RddOrEsfaIntervention { get; set; } - public string RddOrEsfaInterventionDetail { get; set; } - public string TypeOfTransfer { get; set; } - public string OtherTransferTypeDescription { get; set; } - public DateTime? TransferFirstDiscussed { get; set; } - public DateTime? TargetDateForTransfer { get; set; } - public DateTime? HtbDate { get; set; } - public bool? HasTransferFirstDiscussedDate { get; set; } - public bool? HasTargetDateForTransfer { get; set; } - public bool? HasHtbDate { get; set; } - public string ProjectRationale { get; set; } - public string TrustSponsorRationale { get; set; } - public string State { get; set; } - public string Status { get; set; } - - public bool? AnyRisks { get; set; } - public bool? HighProfileShouldBeConsidered { get; set; } - public string HighProfileFurtherSpecification { get; set; } - public bool? ComplexLandAndBuildingShouldBeConsidered { get; set; } - public string ComplexLandAndBuildingFurtherSpecification { get; set; } - public bool? FinanceAndDebtShouldBeConsidered { get; set; } - public string FinanceAndDebtFurtherSpecification { get; set; } - - public bool? OtherRisksShouldBeConsidered { get; set; } - - public bool? EqualitiesImpactAssessmentConsidered { get; set; } - - [MaxLength(20000)] - public string OtherRisksFurtherSpecification { get; set; } - public string OtherBenefitValue { get; set; } - public string Author { get; set; } - public string Recommendation { get; set; } - public string IncomingTrustAgreement { get; set; } - public string DiocesanConsent { get; set; } - public string OutgoingTrustConsent { get; set; } - public bool? LegalRequirementsSectionIsCompleted { get; set; } - public bool? FeatureSectionIsCompleted { get; set; } - public bool? BenefitsSectionIsCompleted { get; set; } - public bool? RationaleSectionIsCompleted { get; set; } - public string AssignedUserFullName { get; set; } - public string AssignedUserEmailAddress { get; set; } - public Guid? AssignedUserId { get; set; } - - public virtual ICollection - AcademyTransferProjectIntendedTransferBenefits { get; set; } - - public virtual ICollection TransferringAcademies { get; set; } - - public DateTime? CreatedOn { get; set; } - } -} diff --git a/TramsDataApi/DatabaseModels/TramsDbContext.cs b/TramsDataApi/DatabaseModels/TramsDbContext.cs index 29bb1015..739a6794 100644 --- a/TramsDataApi/DatabaseModels/TramsDbContext.cs +++ b/TramsDataApi/DatabaseModels/TramsDbContext.cs @@ -12,10 +12,6 @@ public TramsDbContext(DbContextOptions options) : base(options) { } - - public virtual DbSet AcademyTransferProjectIntendedTransferBenefits { get; set; } - public virtual DbSet AcademyTransferProjects { get; set; } - public virtual DbSet TransferringAcademies { get; set; } public virtual DbSet FssProjects { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) @@ -27,71 +23,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) } protected override void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.Entity(entity => - { - entity.ToTable("AcademyTransferProjectIntendedTransferBenefits", "sdd"); - - entity.Property(e => e.Id).HasColumnName("id"); - - entity.Property(e => e.FkAcademyTransferProjectId).HasColumnName("fk_AcademyTransferProjectId"); - - entity.Property(e => e.SelectedBenefit).IsRequired(); - - entity.HasOne(d => d.FkAcademyTransferProject) - .WithMany(p => p.AcademyTransferProjectIntendedTransferBenefits) - .HasForeignKey(d => d.FkAcademyTransferProjectId) - .HasConstraintName("FK__AcademyTr__fk_Ac__4316F928"); - }); - - modelBuilder.HasSequence("sequence_AcademyTransferProjectUrn", "sdd").HasMin(10003000).StartsAt(10003000); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id) - .HasName("PK__AcademyT__C5B214360AF6201A"); - - entity.ToTable("AcademyTransferProjects", "sdd"); - - entity.HasIndex(e => e.Urn) - .HasName("AcademyTransferProjectUrn"); - - entity.Property(e => e.Urn) - .HasDefaultValueSql("NEXT VALUE FOR sdd.sequence_AcademyTransferProjectUrn"); - - entity.Property(e => e.HtbDate).HasColumnType("date"); - - entity.Property(e => e.OutgoingTrustUkprn) - .IsRequired() - .HasMaxLength(8); - - entity.Property(e => e.TargetDateForTransfer).HasColumnType("date"); - entity.Property(e => e.TransferFirstDiscussed).HasColumnType("date"); - entity.Property(e => e.AssignedUserId).HasColumnType("uniqueidentifier"); - entity.Property(e => e.AssignedUserFullName).HasColumnType("nvarchar(max)"); - entity.Property(e => e.AssignedUserEmailAddress).HasColumnType("nvarchar(max)"); - }); - - modelBuilder.Entity(entity => - { - entity.ToTable("TransferringAcademies", "sdd"); - - entity.Property(e => e.Id).HasColumnName("id"); - - entity.Property(e => e.FkAcademyTransferProjectId).HasColumnName("fk_AcademyTransferProjectId"); - - entity.Property(e => e.IncomingTrustUkprn).HasMaxLength(8); - - entity.Property(e => e.OutgoingAcademyUkprn) - .IsRequired() - .HasMaxLength(8); - - entity.HasOne(d => d.FkAcademyTransferProject) - .WithMany(p => p.TransferringAcademies) - .HasForeignKey(d => d.FkAcademyTransferProjectId) - .HasConstraintName("FK__Transferr__fk_Ac__403A8C7D"); - }); - + { modelBuilder.Entity(entity => { entity.ToView("vw_Fss_ProjectData", "fsg"); diff --git a/TramsDataApi/DatabaseModels/TransferringAcademies.cs b/TramsDataApi/DatabaseModels/TransferringAcademies.cs deleted file mode 100644 index fcbb32c8..00000000 --- a/TramsDataApi/DatabaseModels/TransferringAcademies.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; - -// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled. -// If you have enabled NRTs for your project, then un-comment the following line: -// #nullable disable - -namespace TramsDataApi.DatabaseModels -{ - public partial class TransferringAcademies - { - public int Id { get; set; } - public int? FkAcademyTransferProjectId { get; set; } - public string OutgoingAcademyUkprn { get; set; } - public string IncomingTrustUkprn { get; set; } - - public string PupilNumbersAdditionalInformation { get; set; } - public string LatestOfstedReportAdditionalInformation { get; set; } - public string KeyStage2PerformanceAdditionalInformation { get; set; } - public string KeyStage4PerformanceAdditionalInformation { get; set; } - public string KeyStage5PerformanceAdditionalInformation { get; set; } - - public virtual AcademyTransferProjects FkAcademyTransferProject { get; set; } - } -} diff --git a/TramsDataApi/Factories/AcademyTransferProjectFactory.cs b/TramsDataApi/Factories/AcademyTransferProjectFactory.cs deleted file mode 100644 index f61bcffb..00000000 --- a/TramsDataApi/Factories/AcademyTransferProjectFactory.cs +++ /dev/null @@ -1,183 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using TramsDataApi.DatabaseModels; -using TramsDataApi.RequestModels; -using TramsDataApi.RequestModels.AcademyTransferProject; -using TramsDataApi.Services; - -namespace TramsDataApi.Factories -{ - public static class AcademyTransferProjectFactory - { - public static AcademyTransferProjects Create(AcademyTransferProjectRequest request) - { - var transferFirstDiscussed = ParseDate(request?.Dates?.TransferFirstDiscussed); - var targetDateForTransfer = ParseDate(request?.Dates?.TargetDateForTransfer); - var htbDate = ParseDate(request?.Dates?.HtbDate); - - return new AcademyTransferProjects - { - ProjectReference = request?.ProjectReference, - OutgoingTrustUkprn = request.OutgoingTrustUkprn, - WhoInitiatedTheTransfer = request.Features?.WhoInitiatedTheTransfer, - RddOrEsfaIntervention = request.Features?.RddOrEsfaIntervention, - RddOrEsfaInterventionDetail = request.Features?.RddOrEsfaInterventionDetail, - TypeOfTransfer = request.Features?.TypeOfTransfer, - OtherTransferTypeDescription = request.Features?.OtherTransferTypeDescription, - TransferFirstDiscussed = transferFirstDiscussed, - TargetDateForTransfer = targetDateForTransfer, - HtbDate = htbDate, - ProjectRationale = request.Rationale?.ProjectRationale, - TrustSponsorRationale = request.Rationale?.TrustSponsorRationale, - State = request.State, - Status = request.Status, - Author = request.GeneralInformation?.Author, - Recommendation = request.GeneralInformation?.Recommendation, - AnyRisks = request.Benefits?.AnyRisks, - HighProfileShouldBeConsidered = request.Benefits?.OtherFactorsToConsider?.HighProfile?.ShouldBeConsidered, - HighProfileFurtherSpecification = request.Benefits?.OtherFactorsToConsider?.HighProfile?.FurtherSpecification, - ComplexLandAndBuildingShouldBeConsidered = request.Benefits?.OtherFactorsToConsider?.ComplexLandAndBuilding?.ShouldBeConsidered, - ComplexLandAndBuildingFurtherSpecification = request.Benefits?.OtherFactorsToConsider?.ComplexLandAndBuilding?.FurtherSpecification, - FinanceAndDebtShouldBeConsidered = request.Benefits?.OtherFactorsToConsider?.FinanceAndDebt?.ShouldBeConsidered, - FinanceAndDebtFurtherSpecification = request.Benefits?.OtherFactorsToConsider?.FinanceAndDebt?.FurtherSpecification, - OtherRisksShouldBeConsidered = request.Benefits?.OtherFactorsToConsider?.OtherRisks?.ShouldBeConsidered, - OtherRisksFurtherSpecification = request.Benefits?.OtherFactorsToConsider?.OtherRisks?.FurtherSpecification, - OtherBenefitValue = request.Benefits?.IntendedTransferBenefits.OtherBenefitValue, - EqualitiesImpactAssessmentConsidered = request.Benefits?.EqualitiesImpactAssessmentConsidered, - IncomingTrustAgreement = request.LegalRequirements?.IncomingTrustAgreement, - DiocesanConsent = request.LegalRequirements?.DiocesanConsent, - OutgoingTrustConsent = request.LegalRequirements?.OutgoingTrustConsent, - AcademyTransferProjectIntendedTransferBenefits = ConvertAcademyTransferProjectIntendedTransferBenefits(request.Benefits?.IntendedTransferBenefits?.SelectedBenefits), - TransferringAcademies = ConvertTransferringAcademiesList(request.TransferringAcademies), - FeatureSectionIsCompleted = request.Features?.IsCompleted, - BenefitsSectionIsCompleted = request.Benefits?.IsCompleted, - LegalRequirementsSectionIsCompleted = request.LegalRequirements?.IsCompleted, - RationaleSectionIsCompleted = request.Rationale?.IsCompleted, - HasHtbDate = request.Dates?.HasHtbDate, - HasTransferFirstDiscussedDate = request.Dates?.HasTransferFirstDiscussedDate, - HasTargetDateForTransfer = request.Dates?.HasTargetDateForTransfer, - AssignedUserEmailAddress = request.AssignedUser?.EmailAddress, - AssignedUserFullName = request.AssignedUser?.FullName, - AssignedUserId = request.AssignedUser?.Id, - CreatedOn = DateTimeSource.UtcNow() - }; - } - - private static IList ConvertTransferringAcademiesList(IList transferringAcademiesRequests) - { - if (transferringAcademiesRequests == null) - { - return null; - } - - return transferringAcademiesRequests - .Select(t => new TransferringAcademies - { - OutgoingAcademyUkprn = t.OutgoingAcademyUkprn, - IncomingTrustUkprn = t.IncomingTrustUkprn, - PupilNumbersAdditionalInformation = t.PupilNumbersAdditionalInformation, - LatestOfstedReportAdditionalInformation = t.LatestOfstedReportAdditionalInformation, - KeyStage2PerformanceAdditionalInformation = t.KeyStage2PerformanceAdditionalInformation, - KeyStage4PerformanceAdditionalInformation = t.KeyStage4PerformanceAdditionalInformation, - KeyStage5PerformanceAdditionalInformation = t.KeyStage5PerformanceAdditionalInformation - }) - .ToList(); - } - - private static IList ConvertAcademyTransferProjectIntendedTransferBenefits(IList selectedBenefits) - { - if (selectedBenefits == null) { - return null; - } - - return selectedBenefits.Select(b => new AcademyTransferProjectIntendedTransferBenefits { SelectedBenefit = b }).ToList(); - } - - private static DateTime? ParseDate(string date) - { - return date == null - ? (DateTime?) null - : DateTime.ParseExact(date, "dd/MM/yyyy", CultureInfo.InvariantCulture); - } - - public static AcademyTransferProjects Update(AcademyTransferProjects original, AcademyTransferProjectRequest updateRequest) - { - if (updateRequest == null) - { - return original; - } - - var toMerge = Create(updateRequest); - - original.ProjectReference = toMerge.ProjectReference ?? original.ProjectReference; - original.OutgoingTrustUkprn = toMerge.OutgoingTrustUkprn ?? original.OutgoingTrustUkprn; - original.WhoInitiatedTheTransfer = toMerge?.WhoInitiatedTheTransfer ?? original.WhoInitiatedTheTransfer; - original.RddOrEsfaIntervention = toMerge?.RddOrEsfaIntervention == null - ? original.RddOrEsfaIntervention - : toMerge.RddOrEsfaIntervention; - original.RddOrEsfaInterventionDetail = - toMerge?.RddOrEsfaInterventionDetail ?? original.RddOrEsfaInterventionDetail; - original.TypeOfTransfer = toMerge?.TypeOfTransfer ?? original.TypeOfTransfer; - original.OtherTransferTypeDescription = - toMerge?.OtherTransferTypeDescription ?? original.OtherTransferTypeDescription; - original.TransferFirstDiscussed = (updateRequest.Dates?.HasTransferFirstDiscussedDate ?? true) ? (toMerge.TransferFirstDiscussed ?? original.TransferFirstDiscussed) : null; - original.TargetDateForTransfer = (updateRequest.Dates?.HasTargetDateForTransfer ?? true) ? (toMerge.TargetDateForTransfer ?? original.TargetDateForTransfer) : null; - original.HtbDate = (updateRequest.Dates?.HasHtbDate ?? true) ? (toMerge.HtbDate ?? original.HtbDate) : null; - original.HasHtbDate = toMerge.HasHtbDate ?? original.HasHtbDate; - original.HasTargetDateForTransfer = toMerge.HasTargetDateForTransfer ?? original.HasTargetDateForTransfer; - original.HasTransferFirstDiscussedDate = - toMerge.HasTransferFirstDiscussedDate ?? original.HasTransferFirstDiscussedDate; - original.ProjectRationale = toMerge.ProjectRationale ?? original.ProjectRationale; - original.TrustSponsorRationale = toMerge.TrustSponsorRationale ?? original.TrustSponsorRationale; - original.State = toMerge.State ?? original.State; - original.Status = toMerge.Status ?? original.Status; - original.Author = toMerge.Author ?? original.Author; - original.Recommendation = toMerge.Recommendation ?? original.Recommendation; - original.AnyRisks = toMerge.AnyRisks ?? original.AnyRisks; - original.HighProfileShouldBeConsidered = toMerge.HighProfileShouldBeConsidered == null - ? original.HighProfileShouldBeConsidered - : toMerge.HighProfileShouldBeConsidered; - original.HighProfileFurtherSpecification = - toMerge.HighProfileFurtherSpecification ?? original.HighProfileFurtherSpecification; - original.ComplexLandAndBuildingFurtherSpecification = toMerge.ComplexLandAndBuildingFurtherSpecification ?? - original.ComplexLandAndBuildingFurtherSpecification; - original.ComplexLandAndBuildingShouldBeConsidered = toMerge.ComplexLandAndBuildingShouldBeConsidered == null - ? original.ComplexLandAndBuildingShouldBeConsidered - : toMerge.ComplexLandAndBuildingShouldBeConsidered; - original.FinanceAndDebtShouldBeConsidered = toMerge.FinanceAndDebtShouldBeConsidered == null - ? original.FinanceAndDebtShouldBeConsidered - : toMerge.FinanceAndDebtShouldBeConsidered; - original.FinanceAndDebtFurtherSpecification = toMerge.FinanceAndDebtFurtherSpecification ?? - original.FinanceAndDebtFurtherSpecification; - original.OtherRisksShouldBeConsidered = toMerge.OtherRisksShouldBeConsidered == null - ? original.OtherRisksShouldBeConsidered - : toMerge.OtherRisksShouldBeConsidered; - original.OtherRisksFurtherSpecification = toMerge.OtherRisksFurtherSpecification ?? - original.OtherRisksFurtherSpecification; - original.OtherBenefitValue = toMerge.OtherBenefitValue ?? original.OtherBenefitValue; - original.EqualitiesImpactAssessmentConsidered = toMerge.EqualitiesImpactAssessmentConsidered ?? - original.EqualitiesImpactAssessmentConsidered; - original.DiocesanConsent = toMerge.DiocesanConsent ?? original.DiocesanConsent; - original.OutgoingTrustConsent = toMerge.OutgoingTrustConsent ?? original.OutgoingTrustConsent; - original.IncomingTrustAgreement = toMerge.IncomingTrustAgreement ?? original.IncomingTrustAgreement; - original.TransferringAcademies = toMerge.TransferringAcademies ?? original.TransferringAcademies; - - original.FeatureSectionIsCompleted = toMerge.FeatureSectionIsCompleted ?? original.FeatureSectionIsCompleted; - original.BenefitsSectionIsCompleted = toMerge.BenefitsSectionIsCompleted ?? original.BenefitsSectionIsCompleted; - original.LegalRequirementsSectionIsCompleted = toMerge.LegalRequirementsSectionIsCompleted ?? original.LegalRequirementsSectionIsCompleted; - original.RationaleSectionIsCompleted = toMerge.RationaleSectionIsCompleted ?? original.RationaleSectionIsCompleted; - - original.AcademyTransferProjectIntendedTransferBenefits = - toMerge.AcademyTransferProjectIntendedTransferBenefits ?? - original.AcademyTransferProjectIntendedTransferBenefits; - - original.AssignedUserId = toMerge?.AssignedUserId ?? original.AssignedUserId; - original.AssignedUserFullName = toMerge?.AssignedUserFullName ?? original.AssignedUserFullName; - original.AssignedUserEmailAddress = toMerge?.AssignedUserEmailAddress ?? original.AssignedUserEmailAddress; - - return original; - } - } -} diff --git a/TramsDataApi/Factories/AcademyTransferProjectResponseFactory.cs b/TramsDataApi/Factories/AcademyTransferProjectResponseFactory.cs deleted file mode 100644 index a09985fa..00000000 --- a/TramsDataApi/Factories/AcademyTransferProjectResponseFactory.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System.Globalization; -using System.Linq; -using TramsDataApi.DatabaseModels; -using TramsDataApi.ResponseModels; -using TramsDataApi.ResponseModels.AcademyTransferProject; - -namespace TramsDataApi.Factories -{ - public static class AcademyTransferProjectResponseFactory - { - public static AcademyTransferProjectResponse Create(AcademyTransferProjects model) - { - if (model == null) - { - return null; - } - - var transferringAcademies = model.TransferringAcademies - .Select(a => new TransferringAcademiesResponse - { - IncomingTrustUkprn = a.IncomingTrustUkprn, - OutgoingAcademyUkprn = a.OutgoingAcademyUkprn, - PupilNumbersAdditionalInformation = a.PupilNumbersAdditionalInformation, - LatestOfstedReportAdditionalInformation = a.LatestOfstedReportAdditionalInformation, - KeyStage2PerformanceAdditionalInformation = a.KeyStage2PerformanceAdditionalInformation, - KeyStage4PerformanceAdditionalInformation = a.KeyStage4PerformanceAdditionalInformation, - KeyStage5PerformanceAdditionalInformation = a.KeyStage5PerformanceAdditionalInformation - }) - .ToList(); - - var features = new AcademyTransferProjectFeaturesResponse - { - WhoInitiatedTheTransfer = model.WhoInitiatedTheTransfer, - RddOrEsfaIntervention = model.RddOrEsfaIntervention, - RddOrEsfaInterventionDetail = model.RddOrEsfaInterventionDetail, - TypeOfTransfer = model.TypeOfTransfer, - OtherTransferTypeDescription = model.OtherTransferTypeDescription, - IsCompleted = model.FeatureSectionIsCompleted - }; - - var dates = new AcademyTransferProjectDatesResponse - { - TransferFirstDiscussed = - model.TransferFirstDiscussed?.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture), - TargetDateForTransfer = - model.TargetDateForTransfer?.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture), - HtbDate = model.HtbDate?.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture), - HasHtbDate = model.HasHtbDate, - HasTargetDateForTransfer = model.HasTargetDateForTransfer, - HasTransferFirstDiscussedDate = model.HasTransferFirstDiscussedDate - }; - - var intendedTransferBenefits = new IntendedTransferBenefitResponse - { - OtherBenefitValue = model.OtherBenefitValue, - SelectedBenefits = model.AcademyTransferProjectIntendedTransferBenefits? - .Select(b => b.SelectedBenefit).ToList() - }; - - var otherFactorsToConsider = new OtherFactorsToConsiderResponse - { - HighProfile = new BenefitConsideredFactorResponse - { - ShouldBeConsidered = model.HighProfileShouldBeConsidered, - FurtherSpecification = model.HighProfileFurtherSpecification - }, - ComplexLandAndBuilding = new BenefitConsideredFactorResponse - { - ShouldBeConsidered = model.ComplexLandAndBuildingShouldBeConsidered, - FurtherSpecification = model.ComplexLandAndBuildingFurtherSpecification - }, - FinanceAndDebt = new BenefitConsideredFactorResponse - { - ShouldBeConsidered = model.FinanceAndDebtShouldBeConsidered, - FurtherSpecification = model.FinanceAndDebtFurtherSpecification - }, - OtherRisks = new BenefitConsideredFactorResponse - { - ShouldBeConsidered = model.OtherRisksShouldBeConsidered, - FurtherSpecification = model.OtherRisksFurtherSpecification - } - }; - - return new AcademyTransferProjectResponse - { - ProjectUrn = model.Urn.ToString(), - ProjectReference = model.ProjectReference, - OutgoingTrustUkprn = model.OutgoingTrustUkprn, - TransferringAcademies = transferringAcademies, - Features = features, - Dates = dates, - Benefits = new AcademyTransferProjectBenefitsResponse - { - IntendedTransferBenefits = intendedTransferBenefits, - OtherFactorsToConsider = otherFactorsToConsider, - EqualitiesImpactAssessmentConsidered = model.EqualitiesImpactAssessmentConsidered, - IsCompleted = model.BenefitsSectionIsCompleted, - AnyRisks = model.AnyRisks - }, - LegalRequirements = new AcademyTransferProjectLegalRequirementsResponse - { - IncomingTrustAgreement = model.IncomingTrustAgreement, - DiocesanConsent = model.DiocesanConsent, - OutgoingTrustConsent = model.OutgoingTrustConsent, - IsCompleted = model.LegalRequirementsSectionIsCompleted, - }, - Rationale = new AcademyTransferProjectRationaleResponse - { - ProjectRationale = model.ProjectRationale, - TrustSponsorRationale = model.TrustSponsorRationale, - IsCompleted = model.RationaleSectionIsCompleted - }, - GeneralInformation = new AcademyTransferProjectGeneralInformationResponse - { - Author = model.Author, - Recommendation = model.Recommendation - }, - AssignedUser = string.IsNullOrWhiteSpace(model.AssignedUserEmailAddress) - ? null - : new AssignedUserResponse - { - FullName = model.AssignedUserFullName, - EmailAddress = model.AssignedUserEmailAddress, - Id = model.AssignedUserId - }, - State = model.State, - Status = model.Status - }; - } - } -} diff --git a/TramsDataApi/Gateways/AcademyTransferProjectGateway.cs b/TramsDataApi/Gateways/AcademyTransferProjectGateway.cs deleted file mode 100644 index 5cbd21ef..00000000 --- a/TramsDataApi/Gateways/AcademyTransferProjectGateway.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.EntityFrameworkCore; -using TramsDataApi.DatabaseModels; - -namespace TramsDataApi.Gateways -{ - public class AcademyTransferProjectGateway : IAcademyTransferProjectGateway - { - private readonly TramsDbContext _tramsDbContext; - - public AcademyTransferProjectGateway(TramsDbContext tramsDbContext) - { - _tramsDbContext = tramsDbContext; - } - - public AcademyTransferProjects SaveAcademyTransferProject(AcademyTransferProjects project) - { - _tramsDbContext.AcademyTransferProjects.Update(project); - _tramsDbContext.SaveChanges(); - - return project; - } - - public AcademyTransferProjects UpdateAcademyTransferProject(AcademyTransferProjects project) - { - - _tramsDbContext.TransferringAcademies.RemoveRange( - _tramsDbContext.TransferringAcademies.Where( - ta => ta.FkAcademyTransferProject == project - ) - ); - _tramsDbContext.AcademyTransferProjectIntendedTransferBenefits.RemoveRange(_tramsDbContext.AcademyTransferProjectIntendedTransferBenefits.Where( - ta => ta.FkAcademyTransferProject == project - ) - ); - _tramsDbContext.AcademyTransferProjects.Update(project); - - _tramsDbContext.SaveChanges(); - - return project; - } - - public Tuple, int> IndexAcademyTransferProjects(int page) - { - var academyTransferProjects = _tramsDbContext.AcademyTransferProjects - .Include(atp => atp.AcademyTransferProjectIntendedTransferBenefits) - .Include(atp => atp.TransferringAcademies); - - return - Tuple.Create, int>( - academyTransferProjects - .OrderByDescending(atp => atp.Id) - .Skip((page - 1) * 10).Take(10).ToList(), - academyTransferProjects.Count()); - } - - public AcademyTransferProjects GetAcademyTransferProjectByUrn(int urn) - { - return _tramsDbContext.AcademyTransferProjects - .Include(atp => atp.AcademyTransferProjectIntendedTransferBenefits) - .Include(atp => atp.TransferringAcademies) - .FirstOrDefault(atp => atp.Urn == urn); - } - - public IEnumerable GetAcademyTransferProjects() - { - return _tramsDbContext.AcademyTransferProjects - .Include(atp => atp.AcademyTransferProjectIntendedTransferBenefits) - .Include(atp => atp.TransferringAcademies); - } - } -} \ No newline at end of file diff --git a/TramsDataApi/Gateways/IAcademyTransferProjectGateway.cs b/TramsDataApi/Gateways/IAcademyTransferProjectGateway.cs deleted file mode 100644 index 9326c5db..00000000 --- a/TramsDataApi/Gateways/IAcademyTransferProjectGateway.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.Query; -using TramsDataApi.DatabaseModels; - -namespace TramsDataApi.Gateways -{ - public interface IAcademyTransferProjectGateway - { - AcademyTransferProjects SaveAcademyTransferProject(AcademyTransferProjects project); - AcademyTransferProjects GetAcademyTransferProjectByUrn(int urn); - AcademyTransferProjects UpdateAcademyTransferProject(AcademyTransferProjects project); - - /// - /// Retrieves the specified page of transfer projects and the total number of projects in the database - /// - /// the page of results to return - /// - /// A containing the requested page of results and the total number of matching - /// entries in the database - /// - /// - /// Page size is hard-coded to ten - /// is 1-based, not zero-based (Page 1 is the first entry, not page zero) - /// - Tuple, int> IndexAcademyTransferProjects(int page); - IEnumerable GetAcademyTransferProjects(); - } -} diff --git a/TramsDataApi/RequestModels/AcademyConversionProject/AddAcademyConversionProjectNoteRequest.cs b/TramsDataApi/RequestModels/AcademyConversionProject/AddAcademyConversionProjectNoteRequest.cs deleted file mode 100644 index 9bc88111..00000000 --- a/TramsDataApi/RequestModels/AcademyConversionProject/AddAcademyConversionProjectNoteRequest.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace TramsDataApi.RequestModels.AcademyConversionProject -{ - public class AddAcademyConversionProjectNoteRequest - { - public string Subject { get; set; } - public string Note { get; set; } - public string Author { get; set; } - } -} diff --git a/TramsDataApi/RequestModels/AcademyConversionProject/GetAcademyConversionProjectByIdRequest.cs b/TramsDataApi/RequestModels/AcademyConversionProject/GetAcademyConversionProjectByIdRequest.cs deleted file mode 100644 index d9a9ce20..00000000 --- a/TramsDataApi/RequestModels/AcademyConversionProject/GetAcademyConversionProjectByIdRequest.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace TramsDataApi.RequestModels.AcademyConversionProject -{ - public class GetAcademyConversionProjectByIdRequest - { - public int Id { get; set; } - } -} diff --git a/TramsDataApi/RequestModels/AcademyConversionProject/GetAcademyConversionProjectNotesByIdRequest.cs b/TramsDataApi/RequestModels/AcademyConversionProject/GetAcademyConversionProjectNotesByIdRequest.cs deleted file mode 100644 index bc5efb36..00000000 --- a/TramsDataApi/RequestModels/AcademyConversionProject/GetAcademyConversionProjectNotesByIdRequest.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace TramsDataApi.RequestModels.AcademyConversionProject -{ - public class GetAcademyConversionProjectNotesByIdRequest - { - public int Id { get; set; } - } -} diff --git a/TramsDataApi/RequestModels/AcademyConversionProject/GetAcademyConversionProjectsByStatusesRequest.cs b/TramsDataApi/RequestModels/AcademyConversionProject/GetAcademyConversionProjectsByStatusesRequest.cs deleted file mode 100644 index 00a48906..00000000 --- a/TramsDataApi/RequestModels/AcademyConversionProject/GetAcademyConversionProjectsByStatusesRequest.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Collections.Generic; - -namespace TramsDataApi.RequestModels.AcademyConversionProject -{ - public class GetAcademyConversionProjectsByStatusesRequest - { public int Count { get; set; } - - public int Page { get; set; } - public List Statuses { get; set; } - - } -} \ No newline at end of file diff --git a/TramsDataApi/RequestModels/AcademyConversionProject/GetAcademyConversionSearchModel.cs b/TramsDataApi/RequestModels/AcademyConversionProject/GetAcademyConversionSearchModel.cs deleted file mode 100644 index 988e4c5d..00000000 --- a/TramsDataApi/RequestModels/AcademyConversionProject/GetAcademyConversionSearchModel.cs +++ /dev/null @@ -1,31 +0,0 @@ -#nullable enable -using System.Collections.Generic; - -namespace TramsDataApi.RequestModels.AcademyConversionProject -{ - public class GetAcademyConversionSearchModel - { - public GetAcademyConversionSearchModel() - { - - } - public GetAcademyConversionSearchModel(int page, int count, string? titleFilter, - IEnumerable? deliveryOfficerQueryString, IEnumerable? regionUrnsQueryString, - IEnumerable? statusQueryString) - { - Page = page; - Count = count; - TitleFilter = titleFilter; - DeliveryOfficerQueryString = deliveryOfficerQueryString; - RegionUrnsQueryString = regionUrnsQueryString; - StatusQueryString = statusQueryString; - } - - public int Page { get; set; } - public int Count { get; set; } - public string? TitleFilter { get; set; } - public IEnumerable? DeliveryOfficerQueryString { get; set; } - public IEnumerable? RegionUrnsQueryString { get; set; } - public IEnumerable? StatusQueryString { get; set; } - } -} diff --git a/TramsDataApi/RequestModels/AcademyConversionProject/GetAllAcademyConversionProjectsRequest.cs b/TramsDataApi/RequestModels/AcademyConversionProject/GetAllAcademyConversionProjectsRequest.cs deleted file mode 100644 index fa27243f..00000000 --- a/TramsDataApi/RequestModels/AcademyConversionProject/GetAllAcademyConversionProjectsRequest.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace TramsDataApi.RequestModels.AcademyConversionProject -{ - public class GetAllAcademyConversionProjectsRequest - { - public int Page { get; set; } - public int Count { get; set; } - } -} diff --git a/TramsDataApi/RequestModels/AcademyConversionProject/ProjectUser.cs b/TramsDataApi/RequestModels/AcademyConversionProject/ProjectUser.cs deleted file mode 100644 index ca687c18..00000000 --- a/TramsDataApi/RequestModels/AcademyConversionProject/ProjectUser.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -namespace TramsDataApi.RequestModels.AcademyConversionProject -{ - public class AssignedUser - { - public AssignedUser() - { - } - - public AssignedUser(Guid? id, string fullName, string emailAddress) - { - Id = id; - FullName = fullName; - EmailAddress = emailAddress; - } - - public string FullName { get; set; } - public string EmailAddress { get; set; } - public Guid? Id { get; set; } - } -} diff --git a/TramsDataApi/RequestModels/AcademyConversionProject/UpdateAcademyConversionProjectRequest.cs b/TramsDataApi/RequestModels/AcademyConversionProject/UpdateAcademyConversionProjectRequest.cs deleted file mode 100644 index f003545f..00000000 --- a/TramsDataApi/RequestModels/AcademyConversionProject/UpdateAcademyConversionProjectRequest.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; - -namespace TramsDataApi.RequestModels.AcademyConversionProject -{ - public class UpdateAcademyConversionProjectRequest - { - public string ProjectStatus { get; set; } - public DateTime? ApplicationReceivedDate { get; set; } - public DateTime? AssignedDate { get; set; } - public DateTime? HeadTeacherBoardDate { get; set; } - public DateTime? OpeningDate { get; set; } - public DateTime? BaselineDate { get; set; } - - //la summary page - public DateTime? LocalAuthorityInformationTemplateSentDate { get; set; } - public DateTime? LocalAuthorityInformationTemplateReturnedDate { get; set; } - public string LocalAuthorityInformationTemplateComments { get; set; } - public string LocalAuthorityInformationTemplateLink { get; set; } - public bool? LocalAuthorityInformationTemplateSectionComplete { get; set; } - - //school/trust info - public string RecommendationForProject { get; set; } - public string Author { get; set; } - public string ClearedBy { get; set; } - public string AcademyOrderRequired { get; set; } - public DateTime? ProposedAcademyOpeningDate { get; set; } - public bool? SchoolAndTrustInformationSectionComplete { get; set; } - public string PreviousHeadTeacherBoardDateQuestion { get; set; } - public DateTime? PreviousHeadTeacherBoardDate { get; set; } - public decimal? ConversionSupportGrantAmount { get; set; } - public string ConversionSupportGrantChangeReason { get; set; } - - //general info - public string PublishedAdmissionNumber { get; set; } - public string ViabilityIssues { get; set; } - public string FinancialDeficit { get; set; } - public bool? IsThisADiocesanTrust { get; set; } - public decimal? DistanceFromSchoolToTrustHeadquarters { get; set; } - public string DistanceFromSchoolToTrustHeadquartersAdditionalInformation { get; set; } - public string MemberOfParliamentName { get; set; } - public string MemberOfParliamentParty { get; set; } - public bool? GeneralInformationSectionComplete { get; set; } - - //school performance ofsted information - public string SchoolPerformanceAdditionalInformation { get; set; } - - // rationale - public string RationaleForProject { get; set; } - public string RationaleForTrust { get; set; } - public bool? RationaleSectionComplete { get; set; } - - // risk and issues - public string RisksAndIssues { get; set; } - public bool? RisksAndIssuesSectionComplete { get; set; } - - // legal requirements - public string GoverningBodyResolution { get; set; } - public string Consultation { get; set; } - public string DiocesanConsent { get; set; } - public string FoundationConsent { get; set; } - public bool? LegalRequirementsSectionComplete { get; set; } - - // school budget info - public DateTime? EndOfCurrentFinancialYear { get; set; } - public decimal? RevenueCarryForwardAtEndMarchCurrentYear { get; set; } - public decimal? CapitalCarryForwardAtEndMarchCurrentYear { get; set; } - public DateTime? EndOfNextFinancialYear { get; set; } - public decimal? ProjectedRevenueBalanceAtEndMarchNextYear { get; set; } - public decimal? CapitalCarryForwardAtEndMarchNextYear { get; set; } - public string SchoolBudgetInformationAdditionalInformation { get; set; } - public bool? SchoolBudgetInformationSectionComplete { get; set; } - - // pupil schools forecast - public string SchoolPupilForecastsAdditionalInformation { get; set; } - public int? YearOneProjectedCapacity { get; set; } - public int? YearOneProjectedPupilNumbers { get; set; } - public int? YearTwoProjectedCapacity { get; set; } - public int? YearTwoProjectedPupilNumbers { get; set; } - public int? YearThreeProjectedCapacity { get; set; } - public int? YearThreeProjectedPupilNumbers { get; set; } - - // key stage performance tables - public string KeyStage2PerformanceAdditionalInformation { get; set; } - public string KeyStage4PerformanceAdditionalInformation { get; set; } - public string KeyStage5PerformanceAdditionalInformation { get; set; } - - public AssignedUser AssignedUser { get; set; } - } -} diff --git a/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectBenefitsRequest.cs b/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectBenefitsRequest.cs deleted file mode 100644 index a13c21f8..00000000 --- a/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectBenefitsRequest.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace TramsDataApi.RequestModels.AcademyTransferProject -{ - public class AcademyTransferProjectBenefitsRequest - { - public IntendedTransferBenefitRequest IntendedTransferBenefits { get; set; } - public OtherFactorsToConsiderRequest OtherFactorsToConsider { get; set; } - public bool? EqualitiesImpactAssessmentConsidered { get; set; } - public bool? AnyRisks { get; set; } - public bool? IsCompleted { get; set; } - - } -} diff --git a/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectDatesRequest.cs b/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectDatesRequest.cs deleted file mode 100644 index 3aa476a4..00000000 --- a/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectDatesRequest.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace TramsDataApi.RequestModels.AcademyTransferProject -{ - public class AcademyTransferProjectDatesRequest - { - public string TransferFirstDiscussed { get; set; } - public bool? HasTransferFirstDiscussedDate { get; set; } - public string TargetDateForTransfer { get; set; } - public bool? HasTargetDateForTransfer { get; set; } - public string HtbDate { get; set; } - public bool? HasHtbDate { get; set; } - } -} \ No newline at end of file diff --git a/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectFeaturesRequest.cs b/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectFeaturesRequest.cs deleted file mode 100644 index 26d36021..00000000 --- a/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectFeaturesRequest.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace TramsDataApi.RequestModels.AcademyTransferProject -{ - public class AcademyTransferProjectFeaturesRequest - { - public string WhoInitiatedTheTransfer { get; set; } - public bool? RddOrEsfaIntervention { get; set; } - public string RddOrEsfaInterventionDetail { get; set; } - public string TypeOfTransfer { get; set; } - public string OtherTransferTypeDescription { get; set; } - public bool? IsCompleted { get; set; } - } -} \ No newline at end of file diff --git a/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectGeneralInformationRequest.cs b/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectGeneralInformationRequest.cs deleted file mode 100644 index dad9065d..00000000 --- a/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectGeneralInformationRequest.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace TramsDataApi.RequestModels.AcademyTransferProject -{ - public class AcademyTransferProjectGeneralInformationRequest - { - public string Author { get; set; } - public string Recommendation { get; set; } - } -} \ No newline at end of file diff --git a/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectLegalRequirementsRequest.cs b/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectLegalRequirementsRequest.cs deleted file mode 100644 index e31e3ce7..00000000 --- a/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectLegalRequirementsRequest.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace TramsDataApi.RequestModels.AcademyTransferProject -{ - public class AcademyTransferProjectLegalRequirementsRequest - { - public string IncomingTrustAgreement{ get; set; } - public string DiocesanConsent{ get; set; } - public string OutgoingTrustConsent{ get; set; } - public bool? IsCompleted { get; set; } - } -} diff --git a/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectRationaleRequest.cs b/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectRationaleRequest.cs deleted file mode 100644 index 42ff8999..00000000 --- a/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectRationaleRequest.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace TramsDataApi.RequestModels.AcademyTransferProject -{ - public class AcademyTransferProjectRationaleRequest - { - public string ProjectRationale { get; set; } - public string TrustSponsorRationale { get; set; } - public bool? IsCompleted { get; set; } - } -} \ No newline at end of file diff --git a/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectRequest.cs b/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectRequest.cs deleted file mode 100644 index 755e93d9..00000000 --- a/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectRequest.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TramsDataApi.RequestModels.AcademyTransferProject -{ - public class AcademyTransferProjectRequest - { - public string OutgoingTrustUkprn { get; set; } - public List TransferringAcademies { get; set; } - public AcademyTransferProjectFeaturesRequest Features { get; set; } - public AcademyTransferProjectDatesRequest Dates { get; set; } - public AcademyTransferProjectBenefitsRequest Benefits { get; set; } - public AcademyTransferProjectLegalRequirementsRequest LegalRequirements { get; set; } - public AcademyTransferProjectRationaleRequest Rationale { get; set; } - public AcademyTransferProjectGeneralInformationRequest GeneralInformation { get; set; } - public AssignedUserRequest AssignedUser { get; set; } - public string State { get; set; } - public string Status { get; set; } - public string ProjectReference { get; set; } - public DateTime? CreatedOn { get; set; } - - } -} \ No newline at end of file diff --git a/TramsDataApi/RequestModels/IntendedTransferBenefitRequest.cs b/TramsDataApi/RequestModels/IntendedTransferBenefitRequest.cs deleted file mode 100644 index a42bc1a8..00000000 --- a/TramsDataApi/RequestModels/IntendedTransferBenefitRequest.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections.Generic; - -namespace TramsDataApi.RequestModels -{ - public class IntendedTransferBenefitRequest - { - public List SelectedBenefits { get; set; } - public string OtherBenefitValue { get; set; } - } -} \ No newline at end of file diff --git a/TramsDataApi/RequestModels/TransferringAcademiesRequest.cs b/TramsDataApi/RequestModels/TransferringAcademiesRequest.cs deleted file mode 100644 index 9cb44550..00000000 --- a/TramsDataApi/RequestModels/TransferringAcademiesRequest.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace TramsDataApi.RequestModels -{ - public class TransferringAcademiesRequest - { - public string OutgoingAcademyUkprn { get; set; } - public string IncomingTrustUkprn { get; set; } - public string PupilNumbersAdditionalInformation { get; set; } - public string LatestOfstedReportAdditionalInformation { get; set; } - public string KeyStage2PerformanceAdditionalInformation { get; set; } - public string KeyStage4PerformanceAdditionalInformation { get; set; } - public string KeyStage5PerformanceAdditionalInformation { get; set; } - } -} \ No newline at end of file diff --git a/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectBenefitsResponse.cs b/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectBenefitsResponse.cs deleted file mode 100644 index 6a69cba4..00000000 --- a/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectBenefitsResponse.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace TramsDataApi.ResponseModels.AcademyTransferProject -{ - public class AcademyTransferProjectBenefitsResponse - { - public IntendedTransferBenefitResponse IntendedTransferBenefits { get; set; } - public OtherFactorsToConsiderResponse OtherFactorsToConsider { get; set; } - public bool? EqualitiesImpactAssessmentConsidered { get; set; } - public bool? IsCompleted { get; set; } - public bool? AnyRisks { get; set; } - - } -} diff --git a/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectDatesResponse.cs b/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectDatesResponse.cs deleted file mode 100644 index f3f2a2e4..00000000 --- a/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectDatesResponse.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace TramsDataApi.ResponseModels.AcademyTransferProject -{ - public class AcademyTransferProjectDatesResponse - { - public string TransferFirstDiscussed { get; set; } - public string TargetDateForTransfer { get; set; } - public string HtbDate { get; set; } - public string HtbDateInserted { get; set; } - public bool? HasTransferFirstDiscussedDate { get; set; } - public bool? HasTargetDateForTransfer { get; set; } - public bool? HasHtbDate { get; set; } - public bool? HasHtbDateInserted { get; set; } - } -} \ No newline at end of file diff --git a/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectFeaturesResponse.cs b/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectFeaturesResponse.cs deleted file mode 100644 index b4fc4148..00000000 --- a/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectFeaturesResponse.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace TramsDataApi.ResponseModels.AcademyTransferProject -{ - public class AcademyTransferProjectFeaturesResponse - { - public string WhoInitiatedTheTransfer { get; set; } - public bool? RddOrEsfaIntervention { get; set; } - public string RddOrEsfaInterventionDetail { get; set; } - public string TypeOfTransfer { get; set; } - public string OtherTransferTypeDescription { get; set; } - public bool? IsCompleted { get; set; } - } -} \ No newline at end of file diff --git a/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectGeneralInformationResponse.cs b/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectGeneralInformationResponse.cs deleted file mode 100644 index 37c2f6ed..00000000 --- a/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectGeneralInformationResponse.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace TramsDataApi.ResponseModels.AcademyTransferProject -{ - public class AcademyTransferProjectGeneralInformationResponse - { - public string Author { get; set; } - public string Recommendation { get; set; } - } -} \ No newline at end of file diff --git a/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectLegalRequirementsResponse.cs b/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectLegalRequirementsResponse.cs deleted file mode 100644 index c7444385..00000000 --- a/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectLegalRequirementsResponse.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace TramsDataApi.ResponseModels.AcademyTransferProject -{ - public class AcademyTransferProjectLegalRequirementsResponse - { - public string IncomingTrustAgreement { get; set; } - public string DiocesanConsent { get; set; } - public string OutgoingTrustConsent { get; set; } - public bool? IsCompleted { get; set; } - } -} diff --git a/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectRationaleResponse.cs b/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectRationaleResponse.cs deleted file mode 100644 index d61d912d..00000000 --- a/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectRationaleResponse.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace TramsDataApi.ResponseModels.AcademyTransferProject -{ - public class AcademyTransferProjectRationaleResponse - { - public string ProjectRationale { get; set; } - public string TrustSponsorRationale { get; set; } - public bool? IsCompleted { get; set; } - } -} \ No newline at end of file diff --git a/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectResponse.cs b/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectResponse.cs deleted file mode 100644 index e722b688..00000000 --- a/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectResponse.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Collections.Generic; - -namespace TramsDataApi.ResponseModels.AcademyTransferProject -{ - public class AcademyTransferProjectResponse - { - public string ProjectUrn { get; set; } - - public string ProjectReference { get; set; } - public string OutgoingTrustUkprn { get; set; } - public List TransferringAcademies { get; set; } - public AcademyTransferProjectFeaturesResponse Features { get; set; } - public AcademyTransferProjectDatesResponse Dates { get; set; } - public AcademyTransferProjectBenefitsResponse Benefits { get; set; } - public AcademyTransferProjectLegalRequirementsResponse LegalRequirements { get; set; } - public AcademyTransferProjectRationaleResponse Rationale { get; set; } - public AcademyTransferProjectGeneralInformationResponse GeneralInformation { get; set; } - public AssignedUserResponse AssignedUser { get; set; } - public string State { get; set; } - public string Status { get; set; } - } -} \ No newline at end of file diff --git a/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectSummaryResponse.cs b/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectSummaryResponse.cs deleted file mode 100644 index cdce778c..00000000 --- a/TramsDataApi/ResponseModels/AcademyTransferProject/AcademyTransferProjectSummaryResponse.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; - -namespace TramsDataApi.ResponseModels.AcademyTransferProject -{ - public class AcademyTransferProjectSummaryResponse - { - public string ProjectUrn { get; set; } - public string ProjectReference { get; set; } - public string OutgoingTrustUkprn { get; set; } - public string OutgoingTrustName { get; set; } - public string OutgoingTrustLeadRscRegion { get; set; } - public List TransferringAcademies { get; set; } - public AssignedUserResponse AssignedUser { get; set; } - } -} \ No newline at end of file diff --git a/TramsDataApi/ResponseModels/IntendedTransferBenefitResponse.cs b/TramsDataApi/ResponseModels/IntendedTransferBenefitResponse.cs deleted file mode 100644 index 0b5dc3e3..00000000 --- a/TramsDataApi/ResponseModels/IntendedTransferBenefitResponse.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections.Generic; - -namespace TramsDataApi.ResponseModels -{ - public class IntendedTransferBenefitResponse - { - public List SelectedBenefits { get; set; } - public string OtherBenefitValue { get; set; } - } -} \ No newline at end of file diff --git a/TramsDataApi/ResponseModels/TransferringAcademiesResponse.cs b/TramsDataApi/ResponseModels/TransferringAcademiesResponse.cs deleted file mode 100644 index 54320a18..00000000 --- a/TramsDataApi/ResponseModels/TransferringAcademiesResponse.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.ComponentModel.DataAnnotations.Schema; - -namespace TramsDataApi.ResponseModels -{ - public class TransferringAcademiesResponse - { - public string OutgoingAcademyUkprn { get; set; } - public string IncomingTrustUkprn { get; set; } - public string IncomingTrustName { get; set; } - public string IncomingTrustLeadRscRegion { get; set; } - - public string PupilNumbersAdditionalInformation { get; set; } - public string LatestOfstedReportAdditionalInformation { get; set; } - public string KeyStage2PerformanceAdditionalInformation { get; set; } - public string KeyStage4PerformanceAdditionalInformation { get; set; } - public string KeyStage5PerformanceAdditionalInformation { get; set; } - } -} \ No newline at end of file diff --git a/TramsDataApi/Startup.cs b/TramsDataApi/Startup.cs index b7ae7784..0000e94b 100644 --- a/TramsDataApi/Startup.cs +++ b/TramsDataApi/Startup.cs @@ -49,14 +49,7 @@ public void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddScoped(); services.AddScoped(); - services.AddScoped(); - - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/TramsDataApi/UseCases/CreateAcademyTransferProject.cs b/TramsDataApi/UseCases/CreateAcademyTransferProject.cs deleted file mode 100644 index 7264ad50..00000000 --- a/TramsDataApi/UseCases/CreateAcademyTransferProject.cs +++ /dev/null @@ -1,25 +0,0 @@ -using TramsDataApi.DatabaseModels; -using TramsDataApi.Factories; -using TramsDataApi.Gateways; -using TramsDataApi.RequestModels.AcademyTransferProject; -using TramsDataApi.ResponseModels.AcademyTransferProject; - -namespace TramsDataApi.UseCases -{ - public class CreateAcademyTransferProject : ICreateAcademyTransferProject - { - private readonly IAcademyTransferProjectGateway _academyTransferProjectGateway; - public CreateAcademyTransferProject(IAcademyTransferProjectGateway academyTransferProjectGateway) - { - _academyTransferProjectGateway = academyTransferProjectGateway; - } - - public AcademyTransferProjectResponse Execute(AcademyTransferProjectRequest request) - { - AcademyTransferProjects academyTransferProjectToCreate = AcademyTransferProjectFactory.Create(request); - AcademyTransferProjects createdAcademyTransferModel = - _academyTransferProjectGateway.SaveAcademyTransferProject(academyTransferProjectToCreate); - return AcademyTransferProjectResponseFactory.Create(createdAcademyTransferModel); - } - } -} \ No newline at end of file diff --git a/TramsDataApi/UseCases/GetAcademyTransferProject.cs b/TramsDataApi/UseCases/GetAcademyTransferProject.cs deleted file mode 100644 index 379fdf0a..00000000 --- a/TramsDataApi/UseCases/GetAcademyTransferProject.cs +++ /dev/null @@ -1,22 +0,0 @@ -using TramsDataApi.Factories; -using TramsDataApi.Gateways; -using TramsDataApi.ResponseModels.AcademyTransferProject; - -namespace TramsDataApi.UseCases -{ - public class GetAcademyTransferProject : IGetAcademyTransferProject - { - private readonly IAcademyTransferProjectGateway _academyTransferProjectGateway; - - public GetAcademyTransferProject(IAcademyTransferProjectGateway academyTransferProjectGateway) - { - _academyTransferProjectGateway = academyTransferProjectGateway; - } - - public AcademyTransferProjectResponse Execute(int urn) - { - return AcademyTransferProjectResponseFactory - .Create(_academyTransferProjectGateway.GetAcademyTransferProjectByUrn(urn)); - } - } -} \ No newline at end of file diff --git a/TramsDataApi/UseCases/ICreateAcademyTransferProject.cs b/TramsDataApi/UseCases/ICreateAcademyTransferProject.cs deleted file mode 100644 index 57a1a234..00000000 --- a/TramsDataApi/UseCases/ICreateAcademyTransferProject.cs +++ /dev/null @@ -1,10 +0,0 @@ -using TramsDataApi.RequestModels.AcademyTransferProject; -using TramsDataApi.ResponseModels.AcademyTransferProject; - -namespace TramsDataApi.UseCases -{ - public interface ICreateAcademyTransferProject - { - public AcademyTransferProjectResponse Execute(AcademyTransferProjectRequest request); - } -} \ No newline at end of file diff --git a/TramsDataApi/UseCases/IGetAcademyTransferProject.cs b/TramsDataApi/UseCases/IGetAcademyTransferProject.cs deleted file mode 100644 index 69c04678..00000000 --- a/TramsDataApi/UseCases/IGetAcademyTransferProject.cs +++ /dev/null @@ -1,9 +0,0 @@ -using TramsDataApi.ResponseModels.AcademyTransferProject; - -namespace TramsDataApi.UseCases -{ - public interface IGetAcademyTransferProject - { - AcademyTransferProjectResponse Execute(int urn); - } -} \ No newline at end of file diff --git a/TramsDataApi/UseCases/IIndexAcademyTransferProjects.cs b/TramsDataApi/UseCases/IIndexAcademyTransferProjects.cs deleted file mode 100644 index 974ac9fb..00000000 --- a/TramsDataApi/UseCases/IIndexAcademyTransferProjects.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using TramsDataApi.DatabaseModels; -using TramsDataApi.RequestModels; -using TramsDataApi.ResponseModels.AcademyTransferProject; - -namespace TramsDataApi.UseCases -{ - public interface IIndexAcademyTransferProjects - { - public Tuple, int> Execute(int page); - public AcademyTransferProjectSummaryResponse AcademyTransferProjectSummaryResponse(AcademyTransferProjects atp); - } -} \ No newline at end of file diff --git a/TramsDataApi/UseCases/ISearchAcademyTransferProjects.cs b/TramsDataApi/UseCases/ISearchAcademyTransferProjects.cs deleted file mode 100644 index 2ead9104..00000000 --- a/TramsDataApi/UseCases/ISearchAcademyTransferProjects.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Threading.Tasks; -using TramsDataApi.RequestModels; -using TramsDataApi.ResponseModels.AcademyTransferProject; - -namespace TramsDataApi.UseCases -{ - public interface ISearchAcademyTransferProjects - { - Task> Execute(int page, int count, int? urn, string title); - } -} diff --git a/TramsDataApi/UseCases/IUpdateAcademyTransferProject.cs b/TramsDataApi/UseCases/IUpdateAcademyTransferProject.cs deleted file mode 100644 index cbe04d64..00000000 --- a/TramsDataApi/UseCases/IUpdateAcademyTransferProject.cs +++ /dev/null @@ -1,10 +0,0 @@ -using TramsDataApi.RequestModels.AcademyTransferProject; -using TramsDataApi.ResponseModels.AcademyTransferProject; - -namespace TramsDataApi.UseCases -{ - public interface IUpdateAcademyTransferProject - { - AcademyTransferProjectResponse Execute(int urn, AcademyTransferProjectRequest updateRequest); - } -} \ No newline at end of file diff --git a/TramsDataApi/UseCases/IndexAcademyTransferProjects.cs b/TramsDataApi/UseCases/IndexAcademyTransferProjects.cs deleted file mode 100644 index 07a1ab08..00000000 --- a/TramsDataApi/UseCases/IndexAcademyTransferProjects.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using TramsDataApi.DatabaseModels; -using TramsDataApi.Gateways; -using TramsDataApi.ResponseModels; -using TramsDataApi.ResponseModels.AcademyTransferProject; - -namespace TramsDataApi.UseCases -{ - public class IndexAcademyTransferProjects : IIndexAcademyTransferProjects - { - private readonly IAcademyTransferProjectGateway _academyTransferProjectGateway; - private readonly ITrustGateway _trustGateway; - - public IndexAcademyTransferProjects(IAcademyTransferProjectGateway academyTransferProjectGateway, - ITrustGateway trustGateway) - { - _academyTransferProjectGateway = academyTransferProjectGateway; - _trustGateway = trustGateway; - } - - public Tuple, int> Execute(int page) - { - Tuple, int> listOfAcademyTransferProjects = - _academyTransferProjectGateway.IndexAcademyTransferProjects(page); - - return Tuple.Create, int>( - listOfAcademyTransferProjects.Item1.Select(AcademyTransferProjectSummaryResponse).ToList(), - listOfAcademyTransferProjects.Item2); - } - - public AcademyTransferProjectSummaryResponse AcademyTransferProjectSummaryResponse(AcademyTransferProjects atp) - { - Group outgoingGroup = _trustGateway.GetGroupByUkPrn(atp.OutgoingTrustUkprn); - return new AcademyTransferProjectSummaryResponse - { - ProjectUrn = atp.Urn.ToString(), - ProjectReference = atp.ProjectReference, - OutgoingTrustUkprn = atp.OutgoingTrustUkprn, - OutgoingTrustName = outgoingGroup.GroupName, - OutgoingTrustLeadRscRegion = _trustGateway.GetIfdTrustByGroupId(outgoingGroup.GroupId).LeadRscRegion, - TransferringAcademies = atp.TransferringAcademies.Select(ta => - { - Group group = _trustGateway.GetGroupByUkPrn(ta.IncomingTrustUkprn); - return new TransferringAcademiesResponse - { - OutgoingAcademyUkprn = ta.OutgoingAcademyUkprn, - IncomingTrustUkprn = ta.IncomingTrustUkprn, - IncomingTrustName = group.GroupName, - IncomingTrustLeadRscRegion = _trustGateway.GetIfdTrustByGroupId(group.GroupId).LeadRscRegion, - PupilNumbersAdditionalInformation = ta.PupilNumbersAdditionalInformation, - LatestOfstedReportAdditionalInformation = ta.LatestOfstedReportAdditionalInformation, - KeyStage2PerformanceAdditionalInformation = ta.KeyStage2PerformanceAdditionalInformation, - KeyStage4PerformanceAdditionalInformation = ta.KeyStage4PerformanceAdditionalInformation, - KeyStage5PerformanceAdditionalInformation = ta.KeyStage5PerformanceAdditionalInformation - }; - }).ToList() - }; - } - } -} diff --git a/TramsDataApi/UseCases/SearchAcademyTransferProjects.cs b/TramsDataApi/UseCases/SearchAcademyTransferProjects.cs deleted file mode 100644 index 1d8b1172..00000000 --- a/TramsDataApi/UseCases/SearchAcademyTransferProjects.cs +++ /dev/null @@ -1,123 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using TramsDataApi.DatabaseModels; -using TramsDataApi.Gateways; -using TramsDataApi.RequestModels; -using TramsDataApi.ResponseModels; -using TramsDataApi.ResponseModels.AcademyTransferProject; - -namespace TramsDataApi.UseCases -{ - public class SearchAcademyTransferProjects : ISearchAcademyTransferProjects - { - private readonly IAcademyTransferProjectGateway _academyTransferProjectGateway; - private readonly ITrustGateway _trustGateway; - - public SearchAcademyTransferProjects( - IAcademyTransferProjectGateway academyTransferProjectGateway, - ITrustGateway trustGateway) - { - _academyTransferProjectGateway = academyTransferProjectGateway; - _trustGateway = trustGateway; - } - - public Task> Execute(int page, int count, int? urn, - string title) - { - IEnumerable academyTransferProjects = FilterByUrn( - _academyTransferProjectGateway.GetAcademyTransferProjects(), urn).ToList(); - - IEnumerable projects = - FilterByIncomingTrust(title, AcademyTransferProjectSummaryResponse(academyTransferProjects)); - - var recordTotal = projects.Count(); - projects = projects - // remove any projects without an incoming or outgoing trust. - .Where(p => - !string.IsNullOrEmpty(p.OutgoingTrustUkprn) && !string.IsNullOrEmpty(p.OutgoingTrustName) && - !p.TransferringAcademies.Any(ta => string.IsNullOrEmpty(ta.IncomingTrustUkprn) || string.IsNullOrEmpty(ta.IncomingTrustName))) - .OrderByDescending(atp => atp.ProjectUrn) - .Skip((page - 1) * count).Take(count).ToList(); - - return Task.FromResult(new PagedResult(projects, recordTotal)); - } - - private static IEnumerable FilterByUrn(IEnumerable queryable, - int? urn) - { - if (urn.HasValue) queryable = queryable.Where(p => p.Urn == urn); - - return queryable; - } - - private static IEnumerable FilterByIncomingTrust(string title, - IEnumerable queryable) - { - if (!string.IsNullOrWhiteSpace(title)) - { - queryable = queryable - .Where(p => p.TransferringAcademies != null && p.TransferringAcademies - .Exists(r => r != null && r.IncomingTrustName != null && r.IncomingTrustName.ToLower().Contains(title.ToLower()))) - .ToList(); - } - return queryable; - } - - - public IEnumerable AcademyTransferProjectSummaryResponse( - IEnumerable atp) - { - IEnumerable outgoingGroups = - _trustGateway.GetMultipleGroupsByUkprn(atp.Select(x => x.OutgoingTrustUkprn)).ToList(); - - IEnumerable outgoingTrusts = - _trustGateway.GetMultipleTrustsByGroupId(outgoingGroups.Select(x => x.GroupId)).ToList(); - - IEnumerable incomingGroups = - _trustGateway.GetMultipleGroupsByUkprn(atp.SelectMany(p => - p.TransferringAcademies.Select(a => a.IncomingTrustUkprn))).ToList(); - - IEnumerable incomingTrusts = - _trustGateway.GetMultipleTrustsByGroupId(incomingGroups.Select(g => g.GroupId)).ToList(); - - return atp.Select(x => - { - Group outgoingGroup = outgoingGroups.FirstOrDefault(g => g.Ukprn == x.OutgoingTrustUkprn); - return new AcademyTransferProjectSummaryResponse - { - ProjectUrn = x.Urn.ToString(), - ProjectReference = x.ProjectReference, - OutgoingTrustUkprn = x.OutgoingTrustUkprn, - OutgoingTrustName = outgoingGroup?.GroupName, - OutgoingTrustLeadRscRegion = - outgoingTrusts.FirstOrDefault(t => t.TrustRef == outgoingGroup?.GroupId)?.LeadRscRegion, - AssignedUser = string.IsNullOrWhiteSpace(x.AssignedUserEmailAddress) - ? null - : new AssignedUserResponse - { - EmailAddress = x.AssignedUserEmailAddress, - FullName = x.AssignedUserFullName, - Id = x.AssignedUserId - }, - TransferringAcademies = x.TransferringAcademies.Select(ta => - { - Group group = incomingGroups.FirstOrDefault(g => g.Ukprn == ta.IncomingTrustUkprn); - return new TransferringAcademiesResponse - { - OutgoingAcademyUkprn = ta.OutgoingAcademyUkprn, - IncomingTrustUkprn = ta.IncomingTrustUkprn, - IncomingTrustName = group?.GroupName, - IncomingTrustLeadRscRegion = incomingTrusts.FirstOrDefault(t => t.TrustRef == group?.GroupId)?.LeadRscRegion, - PupilNumbersAdditionalInformation = ta.PupilNumbersAdditionalInformation, - LatestOfstedReportAdditionalInformation = ta.LatestOfstedReportAdditionalInformation, - KeyStage2PerformanceAdditionalInformation = ta.KeyStage2PerformanceAdditionalInformation, - KeyStage4PerformanceAdditionalInformation = ta.KeyStage4PerformanceAdditionalInformation, - KeyStage5PerformanceAdditionalInformation = ta.KeyStage5PerformanceAdditionalInformation - }; - }).ToList() - }; - }); - } - } -} diff --git a/TramsDataApi/UseCases/UpdateAcademyTransferProject.cs b/TramsDataApi/UseCases/UpdateAcademyTransferProject.cs deleted file mode 100644 index 6d0b995c..00000000 --- a/TramsDataApi/UseCases/UpdateAcademyTransferProject.cs +++ /dev/null @@ -1,25 +0,0 @@ -using TramsDataApi.Factories; -using TramsDataApi.Gateways; -using TramsDataApi.RequestModels.AcademyTransferProject; -using TramsDataApi.ResponseModels.AcademyTransferProject; - -namespace TramsDataApi.UseCases -{ - public class UpdateAcademyTransferProject : IUpdateAcademyTransferProject - { - private readonly IAcademyTransferProjectGateway _academyTransferProjectGateway; - - public UpdateAcademyTransferProject(IAcademyTransferProjectGateway academyTransferProjectGateway) - { - _academyTransferProjectGateway = academyTransferProjectGateway; - } - - public AcademyTransferProjectResponse Execute(int urn, AcademyTransferProjectRequest updateRequest) - { - var currentAcademyTransferProject = _academyTransferProjectGateway.GetAcademyTransferProjectByUrn(urn); - var updatedAcademyTransferProject = AcademyTransferProjectFactory.Update(currentAcademyTransferProject, updateRequest); - - return AcademyTransferProjectResponseFactory.Create(_academyTransferProjectGateway.UpdateAcademyTransferProject(updatedAcademyTransferProject)); - } - } -} \ No newline at end of file diff --git a/TramsDataApi/Validators/AcademyTransferProjectRequestValidator.cs b/TramsDataApi/Validators/AcademyTransferProjectRequestValidator.cs deleted file mode 100644 index 602b0166..00000000 --- a/TramsDataApi/Validators/AcademyTransferProjectRequestValidator.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Linq; -using FluentValidation; -using TramsDataApi.RequestModels.AcademyTransferProject; - -namespace TramsDataApi.Validators -{ - public class AcademyTransferProjectRequestValidator : AbstractValidator - { - public AcademyTransferProjectRequestValidator() - { - RuleFor(x => x.OutgoingTrustUkprn).Length(8) - .WithMessage("OutgoingTrustUkprn must be length 8") - .NotNull().WithMessage("OutgoingTrustUkprn must not be null"); - - RuleForEach(x => x.TransferringAcademies).SetValidator(new TransferringAcademiesRequestValidator()); - } - } -} \ No newline at end of file diff --git a/TramsDataApi/Validators/TransferringAcademiesRequestValidator.cs b/TramsDataApi/Validators/TransferringAcademiesRequestValidator.cs deleted file mode 100644 index 8c5113c6..00000000 --- a/TramsDataApi/Validators/TransferringAcademiesRequestValidator.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FluentValidation; -using TramsDataApi.RequestModels; - -namespace TramsDataApi.Validators -{ - public class TransferringAcademiesRequestValidator : AbstractValidator - { - public TransferringAcademiesRequestValidator() - { - RuleFor(x => x.OutgoingAcademyUkprn).Length(8) - .WithMessage("OutgoingTrustUkprn must be length 8") - .NotNull().WithMessage("OutgoingTrustUkprn must not be null"); - } - } -} \ No newline at end of file