diff --git a/TramsDataApi.Test/Factories/AcademyTransferProjectFactoryTests.cs b/TramsDataApi.Test/Factories/AcademyTransferProjectFactoryTests.cs index e13d4be98..866e3bd8d 100644 --- a/TramsDataApi.Test/Factories/AcademyTransferProjectFactoryTests.cs +++ b/TramsDataApi.Test/Factories/AcademyTransferProjectFactoryTests.cs @@ -8,6 +8,7 @@ using TramsDataApi.Factories; using TramsDataApi.RequestModels; using TramsDataApi.RequestModels.AcademyTransferProject; +using TramsDataApi.Services; using Xunit; namespace TramsDataApi.Test.Factories @@ -18,6 +19,8 @@ public class AcademyTransferProjectFactoryTests 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) @@ -69,6 +72,7 @@ public void ReturnsAnAcademyTransferProject_WhenGivenAnInitialAcademyTransferPro FeatureSectionIsCompleted = null, BenefitsSectionIsCompleted = null, LegalRequirementsSectionIsCompleted = null, + CreatedOn = DateTimeSource.UtcNow(), RationaleSectionIsCompleted = null, TransferringAcademies = createRequest.TransferringAcademies .Select(t => new TransferringAcademies @@ -92,6 +96,8 @@ public void ReturnsAnAcademyTransferProject_WhenGivenAnInitialAcademyTransferPro [Fact] public void ReturnsAnAcademyTransferProject_WhenGivenACompleteAcademyTransferProjectRequest() { + DateTime expectedCreateDateTime = DateTime.Now; + DateTimeSource.UtcNow = () => expectedCreateDateTime; var randomGenerator = new RandomGenerator(); var benefitsRequest = Builder.CreateNew() @@ -128,6 +134,7 @@ public void ReturnsAnAcademyTransferProject_WhenGivenACompleteAcademyTransferPro .With(c => c.TransferringAcademies = (List) Builder .CreateListOfSize(5).Build()) + .With(d => d.CreatedOn = expectedCreateDateTime) .Build(); var expected = new AcademyTransferProjects @@ -176,6 +183,7 @@ public void ReturnsAnAcademyTransferProject_WhenGivenACompleteAcademyTransferPro 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(), @@ -613,7 +621,6 @@ public void ReturnsOriginalAcademyTransferProjectWithDatesSetToNull_WhenUpdating AssignedUserEmailAddress = academyTransferProject.AssignedUserEmailAddress, AssignedUserFullName = academyTransferProject.AssignedUserFullName, AssignedUserId = academyTransferProject.AssignedUserId, - CreatedOn = academyTransferProject.CreatedOn }; diff --git a/TramsDataApi/DatabaseModels/AcademyTransferProjects.cs b/TramsDataApi/DatabaseModels/AcademyTransferProjects.cs index 1d953a0aa..27c274f6c 100644 --- a/TramsDataApi/DatabaseModels/AcademyTransferProjects.cs +++ b/TramsDataApi/DatabaseModels/AcademyTransferProjects.cs @@ -71,6 +71,6 @@ public virtual ICollection public virtual ICollection TransferringAcademies { get; set; } - public DateTime CreatedOn { get; set; } + public DateTime? CreatedOn { get; set; } } } diff --git a/TramsDataApi/Factories/AcademyTransferProjectFactory.cs b/TramsDataApi/Factories/AcademyTransferProjectFactory.cs index a1c6303a6..f61bcffb2 100644 --- a/TramsDataApi/Factories/AcademyTransferProjectFactory.cs +++ b/TramsDataApi/Factories/AcademyTransferProjectFactory.cs @@ -5,6 +5,7 @@ using TramsDataApi.DatabaseModels; using TramsDataApi.RequestModels; using TramsDataApi.RequestModels.AcademyTransferProject; +using TramsDataApi.Services; namespace TramsDataApi.Factories { @@ -59,7 +60,8 @@ public static AcademyTransferProjects Create(AcademyTransferProjectRequest reque HasTargetDateForTransfer = request.Dates?.HasTargetDateForTransfer, AssignedUserEmailAddress = request.AssignedUser?.EmailAddress, AssignedUserFullName = request.AssignedUser?.FullName, - AssignedUserId = request.AssignedUser?.Id + AssignedUserId = request.AssignedUser?.Id, + CreatedOn = DateTimeSource.UtcNow() }; } diff --git a/TramsDataApi/Migrations/TramsDb/20230322101755_project-created-on-date.Designer.cs b/TramsDataApi/Migrations/TramsDb/20230322101755_project-created-on-date.Designer.cs deleted file mode 100644 index a174c1695..000000000 --- a/TramsDataApi/Migrations/TramsDb/20230322101755_project-created-on-date.Designer.cs +++ /dev/null @@ -1,831 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using TramsDataApi.DatabaseModels; - -namespace TramsDataApi.Migrations.TramsDb -{ - [DbContext(typeof(TramsDbContext))] - [Migration("20230322101755_project-created-on-date")] - partial class projectcreatedondate - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "3.1.14") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("Relational:Sequence:.AcademyTransferProjectUrns", "'AcademyTransferProjectUrns', '', '10000000', '1', '10000000', '', 'Int32', 'False'") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("TramsDataApi.DatabaseModels.A2BApplication", b => - { - b.Property("ApplicationId") - .HasColumnType("nvarchar(450)"); - - b.Property("ApplicationLeadAuthorId") - .HasColumnType("nvarchar(max)"); - - b.Property("ApplicationLeadAuthorName") - .HasColumnType("nvarchar(max)"); - - b.Property("ApplicationLeadEmail") - .HasColumnType("nvarchar(max)"); - - b.Property("ApplicationRole") - .HasColumnType("nvarchar(max)"); - - b.Property("ApplicationRoleOtherDescription") - .HasColumnType("nvarchar(max)"); - - b.Property("ApplicationStatusId") - .HasColumnType("nvarchar(max)"); - - b.Property("ApplicationSubmitted") - .HasColumnType("bit"); - - b.Property("ApplicationType") - .HasColumnType("nvarchar(max)"); - - b.Property("ApplicationVersion") - .HasColumnType("nvarchar(max)"); - - b.Property("ChangesToLaGovernance") - .HasColumnType("bit"); - - b.Property("ChangesToLaGovernanceExplained") - .HasColumnType("nvarchar(max)"); - - b.Property("ChangesToTrust") - .HasColumnType("bit"); - - b.Property("ChangesToTrustExplained") - .HasColumnType("nvarchar(max)"); - - b.Property("DynamicsApplicationId") - .HasColumnType("uniqueidentifier"); - - b.Property("FormTrustGrowthPlansYesNo") - .HasColumnType("bit"); - - b.Property("FormTrustImprovementApprovedSponsor") - .HasColumnType("nvarchar(max)"); - - b.Property("FormTrustImprovementStrategy") - .HasColumnType("nvarchar(max)"); - - b.Property("FormTrustImprovementSupport") - .HasColumnType("nvarchar(max)"); - - b.Property("FormTrustOpeningDate") - .HasColumnType("datetime2"); - - b.Property("FormTrustPlanForGrowth") - .HasColumnType("nvarchar(max)"); - - b.Property("FormTrustPlansForNoGrowth") - .HasColumnType("nvarchar(max)"); - - b.Property("FormTrustProposedNameOfTrust") - .HasColumnType("nvarchar(max)"); - - b.Property("FormTrustReasonApprovalToConvertAsSat") - .HasColumnType("bit"); - - b.Property("FormTrustReasonApprovedPerson") - .HasColumnType("nvarchar(max)"); - - b.Property("FormTrustReasonForming") - .HasColumnType("nvarchar(max)"); - - b.Property("FormTrustReasonFreedom") - .HasColumnType("nvarchar(max)"); - - b.Property("FormTrustReasonGeoAreas") - .HasColumnType("nvarchar(max)"); - - b.Property("FormTrustReasonImproveTeaching") - .HasColumnType("nvarchar(max)"); - - b.Property("FormTrustReasonVision") - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("TrustApproverEmail") - .HasColumnType("nvarchar(max)"); - - b.Property("TrustApproverName") - .HasColumnType("nvarchar(max)"); - - b.Property("TrustId") - .HasColumnType("nvarchar(max)"); - - b.Property("TrustName") - .HasColumnType("nvarchar(max)"); - - b.HasKey("ApplicationId"); - - b.ToTable("A2BApplication","sdd"); - }); - - modelBuilder.Entity("TramsDataApi.DatabaseModels.A2BApplicationApplyingSchool", b => - { - b.Property("ApplyingSchoolId") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("ApplicationId") - .HasColumnType("nvarchar(450)"); - - b.Property("DiocesePermissionEvidenceDocumentLink") - .HasColumnType("nvarchar(max)"); - - b.Property("DynamicsApplicationId") - .HasColumnType("uniqueidentifier"); - - b.Property("DynamicsApplyingSchoolId") - .HasColumnType("uniqueidentifier"); - - b.Property("FoundationEvidenceDocumentLink") - .HasColumnType("nvarchar(max)"); - - b.Property("GoverningBodyConsentEvidenceDocumentLink") - .HasColumnType("nvarchar(max)"); - - b.Property("LocalAuthorityName") - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("ProjectedPupilNumbersYear1") - .HasColumnType("int"); - - b.Property("ProjectedPupilNumbersYear2") - .HasColumnType("int"); - - b.Property("ProjectedPupilNumbersYear3") - .HasColumnType("int"); - - b.Property("SchoolAdEqualitiesImpactAssessment") - .HasColumnType("bit"); - - b.Property("SchoolAdEqualitiesImpactAssessmentDetails") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolAdFeederSchools") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolAdInspectedButReportNotPublished") - .HasColumnType("bit"); - - b.Property("SchoolAdInspectedReportNotPublishedExplain") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolAdSafeguarding") - .HasColumnType("bit"); - - b.Property("SchoolAdSafeguardingExplained") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolAdSchoolContributionToTrust") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolAddFurtherInformation") - .HasColumnType("bit"); - - b.Property("SchoolBuildLandFutureProgramme") - .HasColumnType("bit"); - - b.Property("SchoolBuildLandGrants") - .HasColumnType("bit"); - - b.Property("SchoolBuildLandGrantsBody") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolBuildLandOwnerExplained") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolBuildLandPFIScheme") - .HasColumnType("bit"); - - b.Property("SchoolBuildLandPFISchemeType") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolBuildLandPriorityBuildingProgramme") - .HasColumnType("bit"); - - b.Property("SchoolBuildLandSharedFacilities") - .HasColumnType("bit"); - - b.Property("SchoolBuildLandSharedFacilitiesExplained") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolBuildLandWorksPlanned") - .HasColumnType("bit"); - - b.Property("SchoolBuildLandWorksPlannedDate") - .HasColumnType("datetime2"); - - b.Property("SchoolBuildLandWorksPlannedExplained") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolCFYCapitalForward") - .HasColumnType("decimal(18,2)"); - - b.Property("SchoolCFYCapitalForwardStatusExplained") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolCFYCapitalIsDeficit") - .HasColumnType("bit"); - - b.Property("SchoolCFYEndDate") - .HasColumnType("datetime2"); - - b.Property("SchoolCFYRevenue") - .HasColumnType("decimal(18,2)"); - - b.Property("SchoolCFYRevenueIsDeficit") - .HasColumnType("bit"); - - b.Property("SchoolCFYRevenueStatusExplained") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolCapacityAssumptions") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolCapacityPublishedAdmissionsNumber") - .HasColumnType("int"); - - b.Property("SchoolConsultationStakeholders") - .HasColumnType("bit"); - - b.Property("SchoolConsultationStakeholdersConsult") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolConversionApproverContactEmail") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolConversionApproverContactName") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolConversionChangeName") - .HasColumnType("bit"); - - b.Property("SchoolConversionChangeNameValue") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolConversionContactChairEmail") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolConversionContactChairName") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolConversionContactChairTel") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolConversionContactHeadEmail") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolConversionContactHeadName") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolConversionContactHeadTel") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolConversionContactRole") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolConversionMainContactOtherEmail") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolConversionMainContactOtherName") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolConversionMainContactOtherRole") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolConversionMainContactOtherTelephone") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolConversionReasonsForJoining") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolConversionTargetDateDate") - .HasColumnType("datetime2"); - - b.Property("SchoolConversionTargetDateDifferent") - .HasColumnType("bit"); - - b.Property("SchoolConversionTargetDateExplained") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolDeclarationBodyAgree") - .HasColumnType("bit"); - - b.Property("SchoolDeclarationSignedByEmail") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolDeclarationSignedById") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolDeclarationSignedByName") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolDeclarationTeacherChair") - .HasColumnType("bit"); - - b.Property("SchoolFaithSchool") - .HasColumnType("bit"); - - b.Property("SchoolFaithSchoolDioceseName") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolFinancialInvestigations") - .HasColumnType("bit"); - - b.Property("SchoolFinancialInvestigationsExplain") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolFinancialInvestigationsTrustAware") - .HasColumnType("bit"); - - b.Property("SchoolFurtherInformation") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolLaClosurePlans") - .HasColumnType("bit"); - - b.Property("SchoolLaClosurePlansExplain") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolLaReorganization") - .HasColumnType("bit"); - - b.Property("SchoolLaReorganizationExplain") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolNFYCapitalForward") - .HasColumnType("decimal(18,2)"); - - b.Property("SchoolNFYCapitalForwardStatusExplained") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolNFYCapitalIsDeficit") - .HasColumnType("bit"); - - b.Property("SchoolNFYEndDate") - .HasColumnType("datetime2"); - - b.Property("SchoolNFYRevenue") - .HasColumnType("decimal(18,2)"); - - b.Property("SchoolNFYRevenueIsDeficit") - .HasColumnType("bit"); - - b.Property("SchoolNFYRevenueStatusExplained") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolPFYCapitalForward") - .HasColumnType("decimal(18,2)"); - - b.Property("SchoolPFYCapitalForwardStatusExplained") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolPFYCapitalIsDeficit") - .HasColumnType("bit"); - - b.Property("SchoolPFYEndDate") - .HasColumnType("datetime2"); - - b.Property("SchoolPFYRevenue") - .HasColumnType("decimal(18,2)"); - - b.Property("SchoolPFYRevenueIsDeficit") - .HasColumnType("bit"); - - b.Property("SchoolPFYRevenueStatusExplained") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolPartOfFederation") - .HasColumnType("bit"); - - b.Property("SchoolSACREExemption") - .HasColumnType("bit"); - - b.Property("SchoolSACREExemptionEndDate") - .HasColumnType("datetime2"); - - b.Property("SchoolSupportGrantFundsPaidTo") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolSupportedFoundation") - .HasColumnType("bit"); - - b.Property("SchoolSupportedFoundationBodyName") - .HasColumnType("nvarchar(max)"); - - b.Property("Urn") - .HasColumnType("int"); - - b.HasKey("ApplyingSchoolId"); - - b.HasIndex("ApplicationId"); - - b.ToTable("A2BApplicationApplyingSchool","sdd"); - }); - - modelBuilder.Entity("TramsDataApi.DatabaseModels.A2BApplicationKeyPersons", b => - { - b.Property("KeyPersonId") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("ApplicationId") - .HasColumnType("nvarchar(450)"); - - b.Property("DynamicsKeyPersonId") - .HasColumnType("uniqueidentifier"); - - b.Property("KeyPersonBiography") - .HasColumnType("nvarchar(max)"); - - b.Property("KeyPersonCeoExecutive") - .HasColumnType("bit"); - - b.Property("KeyPersonChairOfTrust") - .HasColumnType("bit"); - - b.Property("KeyPersonDateOfBirth") - .HasColumnType("datetime2"); - - b.Property("KeyPersonFinancialDirector") - .HasColumnType("bit"); - - b.Property("KeyPersonMember") - .HasColumnType("bit"); - - b.Property("KeyPersonOther") - .HasColumnType("bit"); - - b.Property("KeyPersonTrustee") - .HasColumnType("bit"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.HasKey("KeyPersonId"); - - b.HasIndex("ApplicationId"); - - b.ToTable("A2BApplicationKeyPersons","sdd"); - }); - - modelBuilder.Entity("TramsDataApi.DatabaseModels.A2BSchoolLease", b => - { - b.Property("SchoolLeaseId") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("ApplyingSchoolId") - .HasColumnType("int"); - - b.Property("DynamicsSchoolLeaseId") - .HasColumnType("uniqueidentifier"); - - b.Property("SchoolLeaseInterestRate") - .HasColumnType("decimal(18,2)"); - - b.Property("SchoolLeasePaymentToDate") - .HasColumnType("decimal(18,2)"); - - b.Property("SchoolLeasePurpose") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolLeaseRepaymentValue") - .HasColumnType("decimal(18,2)"); - - b.Property("SchoolLeaseResponsibleForAssets") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolLeaseTerm") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolLeaseValueOfAssets") - .HasColumnType("nvarchar(max)"); - - b.HasKey("SchoolLeaseId"); - - b.HasIndex("ApplyingSchoolId"); - - b.ToTable("A2BSchoolLease","sdd"); - }); - - modelBuilder.Entity("TramsDataApi.DatabaseModels.A2BSchoolLoan", b => - { - b.Property("SchoolLoanId") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("ApplyingSchoolId") - .HasColumnType("int"); - - b.Property("DynamicsSchoolLoanId") - .HasColumnType("uniqueidentifier"); - - b.Property("SchoolLoanAmount") - .HasColumnType("decimal(18,2)"); - - b.Property("SchoolLoanInterestRate") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolLoanProvider") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolLoanPurpose") - .HasColumnType("nvarchar(max)"); - - b.Property("SchoolLoanSchedule") - .HasColumnType("nvarchar(max)"); - - b.HasKey("SchoolLoanId"); - - b.HasIndex("ApplyingSchoolId"); - - b.ToTable("A2BSchoolLoan","sdd"); - }); - - modelBuilder.Entity("TramsDataApi.DatabaseModels.AcademyTransferProjectIntendedTransferBenefits", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnName("id") - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("FkAcademyTransferProjectId") - .HasColumnName("fk_AcademyTransferProjectId") - .HasColumnType("int"); - - b.Property("SelectedBenefit") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("FkAcademyTransferProjectId"); - - b.ToTable("AcademyTransferProjectIntendedTransferBenefits","sdd"); - }); - - modelBuilder.Entity("TramsDataApi.DatabaseModels.AcademyTransferProjects", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AnyRisks") - .HasColumnType("bit"); - - b.Property("AssignedUserEmailAddress") - .HasColumnType("nvarchar(max)"); - - b.Property("AssignedUserFullName") - .HasColumnType("nvarchar(max)"); - - b.Property("AssignedUserId") - .HasColumnType("uniqueidentifier"); - - b.Property("Author") - .HasColumnType("nvarchar(max)"); - - b.Property("BenefitsSectionIsCompleted") - .HasColumnType("bit"); - - b.Property("ComplexLandAndBuildingFurtherSpecification") - .HasColumnType("nvarchar(max)"); - - b.Property("ComplexLandAndBuildingShouldBeConsidered") - .HasColumnType("bit"); - - b.Property("CreatedOn") - .HasColumnType("datetime2"); - - b.Property("DiocesanConsent") - .HasColumnType("nvarchar(max)"); - - b.Property("EqualitiesImpactAssessmentConsidered") - .HasColumnType("bit"); - - b.Property("FeatureSectionIsCompleted") - .HasColumnType("bit"); - - b.Property("FinanceAndDebtFurtherSpecification") - .HasColumnType("nvarchar(max)"); - - b.Property("FinanceAndDebtShouldBeConsidered") - .HasColumnType("bit"); - - b.Property("HasHtbDate") - .HasColumnType("bit"); - - b.Property("HasTargetDateForTransfer") - .HasColumnType("bit"); - - b.Property("HasTransferFirstDiscussedDate") - .HasColumnType("bit"); - - b.Property("HighProfileFurtherSpecification") - .HasColumnType("nvarchar(max)"); - - b.Property("HighProfileShouldBeConsidered") - .HasColumnType("bit"); - - b.Property("HtbDate") - .HasColumnType("date"); - - b.Property("IncomingTrustAgreement") - .HasColumnType("nvarchar(max)"); - - b.Property("LegalRequirementsSectionIsCompleted") - .HasColumnType("bit"); - - b.Property("OtherBenefitValue") - .HasColumnType("nvarchar(max)"); - - b.Property("OtherRisksFurtherSpecification") - .HasColumnType("nvarchar(max)") - .HasMaxLength(20000); - - b.Property("OtherRisksShouldBeConsidered") - .HasColumnType("bit"); - - b.Property("OtherTransferTypeDescription") - .HasColumnType("nvarchar(max)"); - - b.Property("OutgoingTrustConsent") - .HasColumnType("nvarchar(max)"); - - b.Property("OutgoingTrustUkprn") - .IsRequired() - .HasColumnType("nvarchar(8)") - .HasMaxLength(8); - - b.Property("ProjectRationale") - .HasColumnType("nvarchar(max)"); - - b.Property("ProjectReference") - .HasColumnType("nvarchar(max)"); - - b.Property("RationaleSectionIsCompleted") - .HasColumnType("bit"); - - b.Property("RddOrEsfaIntervention") - .HasColumnType("bit"); - - b.Property("RddOrEsfaInterventionDetail") - .HasColumnType("nvarchar(max)"); - - b.Property("Recommendation") - .HasColumnType("nvarchar(max)"); - - b.Property("State") - .HasColumnType("nvarchar(max)"); - - b.Property("Status") - .HasColumnType("nvarchar(max)"); - - b.Property("TargetDateForTransfer") - .HasColumnType("date"); - - b.Property("TransferFirstDiscussed") - .HasColumnType("date"); - - b.Property("TrustSponsorRationale") - .HasColumnType("nvarchar(max)"); - - b.Property("TypeOfTransfer") - .HasColumnType("nvarchar(max)"); - - b.Property("Urn") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasDefaultValueSql("NEXT VALUE FOR AcademyTransferProjectUrns"); - - b.Property("WhoInitiatedTheTransfer") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id") - .HasName("PK__AcademyT__C5B214360AF6201A"); - - b.HasIndex("Urn") - .HasName("AcademyTransferProjectUrn"); - - b.ToTable("AcademyTransferProjects","sdd"); - }); - - modelBuilder.Entity("TramsDataApi.DatabaseModels.TransferringAcademies", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnName("id") - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("FkAcademyTransferProjectId") - .HasColumnName("fk_AcademyTransferProjectId") - .HasColumnType("int"); - - b.Property("IncomingTrustUkprn") - .HasColumnType("nvarchar(8)") - .HasMaxLength(8); - - b.Property("KeyStage2PerformanceAdditionalInformation") - .HasColumnType("nvarchar(max)"); - - b.Property("KeyStage4PerformanceAdditionalInformation") - .HasColumnType("nvarchar(max)"); - - b.Property("KeyStage5PerformanceAdditionalInformation") - .HasColumnType("nvarchar(max)"); - - b.Property("LatestOfstedReportAdditionalInformation") - .HasColumnType("nvarchar(max)"); - - b.Property("OutgoingAcademyUkprn") - .IsRequired() - .HasColumnType("nvarchar(8)") - .HasMaxLength(8); - - b.Property("PupilNumbersAdditionalInformation") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("FkAcademyTransferProjectId"); - - b.ToTable("TransferringAcademies","sdd"); - }); - - modelBuilder.Entity("TramsDataApi.DatabaseModels.A2BApplicationApplyingSchool", b => - { - b.HasOne("TramsDataApi.DatabaseModels.A2BApplication", "A2BApplication") - .WithMany("ApplyingSchools") - .HasForeignKey("ApplicationId"); - }); - - modelBuilder.Entity("TramsDataApi.DatabaseModels.A2BApplicationKeyPersons", b => - { - b.HasOne("TramsDataApi.DatabaseModels.A2BApplication", "A2BApplication") - .WithMany("KeyPersons") - .HasForeignKey("ApplicationId"); - }); - - modelBuilder.Entity("TramsDataApi.DatabaseModels.A2BSchoolLease", b => - { - b.HasOne("TramsDataApi.DatabaseModels.A2BApplicationApplyingSchool", "A2BApplicationApplyingSchool") - .WithMany("SchoolLeases") - .HasForeignKey("ApplyingSchoolId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("TramsDataApi.DatabaseModels.A2BSchoolLoan", b => - { - b.HasOne("TramsDataApi.DatabaseModels.A2BApplicationApplyingSchool", "A2BApplicationApplyingSchool") - .WithMany("SchoolLoans") - .HasForeignKey("ApplyingSchoolId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("TramsDataApi.DatabaseModels.AcademyTransferProjectIntendedTransferBenefits", b => - { - b.HasOne("TramsDataApi.DatabaseModels.AcademyTransferProjects", "FkAcademyTransferProject") - .WithMany("AcademyTransferProjectIntendedTransferBenefits") - .HasForeignKey("FkAcademyTransferProjectId") - .HasConstraintName("FK__AcademyTr__fk_Ac__4316F928"); - }); - - modelBuilder.Entity("TramsDataApi.DatabaseModels.TransferringAcademies", b => - { - b.HasOne("TramsDataApi.DatabaseModels.AcademyTransferProjects", "FkAcademyTransferProject") - .WithMany("TransferringAcademies") - .HasForeignKey("FkAcademyTransferProjectId") - .HasConstraintName("FK__Transferr__fk_Ac__403A8C7D"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/TramsDataApi/Migrations/TramsDb/20230322101755_project-created-on-date.cs b/TramsDataApi/Migrations/TramsDb/20230322101755_project-created-on-date.cs deleted file mode 100644 index e743e443a..000000000 --- a/TramsDataApi/Migrations/TramsDb/20230322101755_project-created-on-date.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace TramsDataApi.Migrations.TramsDb -{ - public partial class projectcreatedondate : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - "CreatedOn", - schema: "sdd", - table: "AcademyTransferProjects", - nullable: false, - defaultValueSql: "GETDATE()"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - "CreatedOn", - schema: "sdd", - table: "AcademyTransferProjects"); - } - } -} diff --git a/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectRequest.cs b/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectRequest.cs index 0f893ea1b..755e93d91 100644 --- a/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectRequest.cs +++ b/TramsDataApi/RequestModels/AcademyTransferProject/AcademyTransferProjectRequest.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; namespace TramsDataApi.RequestModels.AcademyTransferProject @@ -16,6 +17,7 @@ public class AcademyTransferProjectRequest 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/Services/DateTimeService.cs b/TramsDataApi/Services/DateTimeService.cs new file mode 100644 index 000000000..8fb3cbadb --- /dev/null +++ b/TramsDataApi/Services/DateTimeService.cs @@ -0,0 +1,27 @@ +using System; + +namespace TramsDataApi.Services +{ + /// + /// Mechanism for retrieving DateTime data that provides a way to intercept and set the returned values to facilitate testing + /// + /// + /// + /// DateTime expected = DateTime.UtcNow; + /// DateTimeSource.UtcNow = () => expected; + /// + /// + public static class DateTimeSource + { + /// + /// Returns the value of unless overridden for testing. + /// + public static Func UtcNow { get; set; } = () => DateTime.UtcNow; + + /// + /// Returns the value of unless overridden for testing. + /// + public static Func UkTime { get; set; } = () => + TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, "GMT Standard Time"); + } +} \ No newline at end of file diff --git a/TramsDataApi/TramsDataApi.csproj b/TramsDataApi/TramsDataApi.csproj index 37482bc9c..7d6fe18f9 100644 --- a/TramsDataApi/TramsDataApi.csproj +++ b/TramsDataApi/TramsDataApi.csproj @@ -23,6 +23,7 @@ + diff --git a/TramsDataApi/UseCases/CreateAcademyTransferProject.cs b/TramsDataApi/UseCases/CreateAcademyTransferProject.cs index 63d50cf48..7264ad507 100644 --- a/TramsDataApi/UseCases/CreateAcademyTransferProject.cs +++ b/TramsDataApi/UseCases/CreateAcademyTransferProject.cs @@ -16,8 +16,8 @@ public CreateAcademyTransferProject(IAcademyTransferProjectGateway academyTransf public AcademyTransferProjectResponse Execute(AcademyTransferProjectRequest request) { - var academyTransferProjectToCreate = AcademyTransferProjectFactory.Create(request); - var createdAcademyTransferModel = + AcademyTransferProjects academyTransferProjectToCreate = AcademyTransferProjectFactory.Create(request); + AcademyTransferProjects createdAcademyTransferModel = _academyTransferProjectGateway.SaveAcademyTransferProject(academyTransferProjectToCreate); return AcademyTransferProjectResponseFactory.Create(createdAcademyTransferModel); }