diff --git a/Dfe.Academies.Academisation.Data/ApplicationAggregate/ApplicationSchoolState.cs b/Dfe.Academies.Academisation.Data/ApplicationAggregate/ApplicationSchoolState.cs index 4eeb9130b..f482408db 100644 --- a/Dfe.Academies.Academisation.Data/ApplicationAggregate/ApplicationSchoolState.cs +++ b/Dfe.Academies.Academisation.Data/ApplicationAggregate/ApplicationSchoolState.cs @@ -138,6 +138,9 @@ public class ApplicationSchoolState : BaseEntity // Reason for joning trust public string? SchoolConversionReasonsForJoining { get; set; } + // MR:- below mods for Dynamics -> SQL server A2B external app conversion + public Guid? DynamicsApplyingSchoolId { get; set; } + public static ApplicationSchoolState MapFromDomain(ISchool applyingSchool) { return new() diff --git a/Dfe.Academies.Academisation.Data/ApplicationAggregate/ApplicationState.cs b/Dfe.Academies.Academisation.Data/ApplicationAggregate/ApplicationState.cs index af6ba580a..04fc2880a 100644 --- a/Dfe.Academies.Academisation.Data/ApplicationAggregate/ApplicationState.cs +++ b/Dfe.Academies.Academisation.Data/ApplicationAggregate/ApplicationState.cs @@ -21,6 +21,15 @@ public class ApplicationState : BaseEntity public FormTrustState? FormTrust { get; set; } public DateTime? ApplicationSubmittedDate { get; set; } + // MR:- below mods for Dynamics -> SQL server A2B external app conversion + public Guid? DynamicsApplicationId { get; set; } + + /// + /// This is in the format $"A2B_{ApplicationId}" + /// Currently calculated by new UI but we need somewhere to store existing data from dynamics + /// + public string? ApplicationReference { get; set; } + public static ApplicationState MapFromDomain(IApplication application, IMapper mapper) { return new() @@ -38,7 +47,8 @@ public static ApplicationState MapFromDomain(IApplication application, IMapper m .ToHashSet(), FormTrust = mapper.Map(application.FormTrust), JoinTrust = mapper.Map(application.JoinTrust), - ApplicationSubmittedDate = application.ApplicationSubmittedDate + ApplicationSubmittedDate = application.ApplicationSubmittedDate, + ApplicationReference = application.ApplicationReference }; } diff --git a/Dfe.Academies.Academisation.Data/ApplicationAggregate/FormTrustState.cs b/Dfe.Academies.Academisation.Data/ApplicationAggregate/FormTrustState.cs index dbc2f56ae..1e65c8c2d 100644 --- a/Dfe.Academies.Academisation.Data/ApplicationAggregate/FormTrustState.cs +++ b/Dfe.Academies.Academisation.Data/ApplicationAggregate/FormTrustState.cs @@ -1,13 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using AutoFixture; -using Dfe.Academies.Academisation.Domain.ApplicationAggregate.Trusts; -using Dfe.Academies.Academisation.Domain.Core.ApplicationAggregate; -using Dfe.Academies.Academisation.IDomain.ApplicationAggregate; +using System.ComponentModel.DataAnnotations.Schema; namespace Dfe.Academies.Academisation.Data.ApplicationAggregate { diff --git a/Dfe.Academies.Academisation.Data/ApplicationAggregate/JoinTrustState.cs b/Dfe.Academies.Academisation.Data/ApplicationAggregate/JoinTrustState.cs index b1ef3c789..7778cbe32 100644 --- a/Dfe.Academies.Academisation.Data/ApplicationAggregate/JoinTrustState.cs +++ b/Dfe.Academies.Academisation.Data/ApplicationAggregate/JoinTrustState.cs @@ -1,13 +1,5 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using AutoFixture; -using Dfe.Academies.Academisation.Domain.ApplicationAggregate.Trusts; +using System.ComponentModel.DataAnnotations.Schema; using Dfe.Academies.Academisation.Domain.Core.ApplicationAggregate; -using Dfe.Academies.Academisation.IDomain.ApplicationAggregate; namespace Dfe.Academies.Academisation.Data.ApplicationAggregate { diff --git a/Dfe.Academies.Academisation.Data/ApplicationAggregate/LeaseState.cs b/Dfe.Academies.Academisation.Data/ApplicationAggregate/LeaseState.cs index 991bddd57..d05d5e834 100644 --- a/Dfe.Academies.Academisation.Data/ApplicationAggregate/LeaseState.cs +++ b/Dfe.Academies.Academisation.Data/ApplicationAggregate/LeaseState.cs @@ -14,7 +14,10 @@ public class LeaseState : BaseEntity public string Purpose { get; set; } public string ValueOfAssets { get; set; } public string ResponsibleForAssets { get; set; } - + + // MR:- below mods for Dynamics -> SQL server A2B external app conversion + public Guid? DynamicsSchoolLeaseId { get; set; } + public static Lease MapFromDomain(ILease lease) { return new Lease(lease.Id, lease.LeaseTerm, lease.RepaymentAmount, lease.InterestRate, lease.PaymentsToDate, lease.Purpose, lease.ValueOfAssets, lease.ResponsibleForAssets); diff --git a/Dfe.Academies.Academisation.Data/ApplicationAggregate/LoanState.cs b/Dfe.Academies.Academisation.Data/ApplicationAggregate/LoanState.cs index c06b1fb55..635fb1f71 100644 --- a/Dfe.Academies.Academisation.Data/ApplicationAggregate/LoanState.cs +++ b/Dfe.Academies.Academisation.Data/ApplicationAggregate/LoanState.cs @@ -19,6 +19,9 @@ public class LoanState : BaseEntity public string Schedule { get; set; } + // MR:- below mods for Dynamics -> SQL server A2B external app conversion + public Guid? DynamicsSchoolLoanId { get; set; } + public static Loan MapFromDomain(ILoan loan) { return new Loan(loan.Id, loan.Amount, loan.Purpose, loan.Provider, loan.InterestRate, loan.Schedule); diff --git a/Dfe.Academies.Academisation.Data/ApplicationAggregate/TrustKeyPersonState.cs b/Dfe.Academies.Academisation.Data/ApplicationAggregate/TrustKeyPersonState.cs index aa6835ad9..80dfa5a2b 100644 --- a/Dfe.Academies.Academisation.Data/ApplicationAggregate/TrustKeyPersonState.cs +++ b/Dfe.Academies.Academisation.Data/ApplicationAggregate/TrustKeyPersonState.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.ComponentModel.DataAnnotations.Schema; using Dfe.Academies.Academisation.Domain.Core.ApplicationAggregate; namespace Dfe.Academies.Academisation.Data.ApplicationAggregate @@ -20,5 +15,8 @@ public class TrustKeyPersonState : BaseEntity public string? ContactEmailAddress { get; set; } public DateTime? DateOfBirth { get; set; } public string Biography { get; set; } + + // MR:- below mods for Dynamics -> SQL server A2B external app conversion + public Guid DynamicsKeyPersonId { get; set; } } } diff --git a/Dfe.Academies.Academisation.Data/Migrations/20221205161027_DataConversionColumns.Designer.cs b/Dfe.Academies.Academisation.Data/Migrations/20221205161027_DataConversionColumns.Designer.cs new file mode 100644 index 000000000..27c651290 --- /dev/null +++ b/Dfe.Academies.Academisation.Data/Migrations/20221205161027_DataConversionColumns.Designer.cs @@ -0,0 +1,1150 @@ +// +using System; +using Dfe.Academies.Academisation.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Dfe.Academies.Academisation.Data.Migrations +{ + [DbContext(typeof(AcademisationContext))] + [Migration("20221205161027_DataConversionColumns")] + partial class DataConversionColumns + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("academisation") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ApplicationAggregate.ApplicationSchoolState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ApproverContactEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("ApproverContactName") + .HasColumnType("nvarchar(max)"); + + b.Property("CapacityAssumptions") + .HasColumnType("nvarchar(max)"); + + b.Property("CapacityPublishedAdmissionsNumber") + .HasColumnType("int"); + + b.Property("ConfirmPaySupportGrantToSchool") + .HasColumnType("bit"); + + b.Property("ContactChairEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("ContactChairName") + .HasColumnType("nvarchar(max)"); + + b.Property("ContactChairTel") + .HasColumnType("nvarchar(max)"); + + b.Property("ContactHeadEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("ContactHeadName") + .HasColumnType("nvarchar(max)"); + + b.Property("ContactHeadTel") + .HasColumnType("nvarchar(max)"); + + b.Property("ContactRole") + .HasColumnType("nvarchar(max)"); + + b.Property("ConversionApplicationId") + .HasColumnType("int"); + + b.Property("ConversionChangeNamePlanned") + .HasColumnType("bit"); + + b.Property("ConversionTargetDate") + .HasColumnType("datetime2"); + + b.Property("ConversionTargetDateExplained") + .HasColumnType("nvarchar(max)"); + + b.Property("ConversionTargetDateSpecified") + .HasColumnType("bit"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("CurrentFinancialYearCapitalCarryForward") + .HasColumnType("decimal(18,2)"); + + b.Property("CurrentFinancialYearCapitalCarryForwardExplained") + .HasColumnType("nvarchar(max)"); + + b.Property("CurrentFinancialYearCapitalCarryForwardFileLink") + .HasColumnType("nvarchar(max)"); + + b.Property("CurrentFinancialYearCapitalCarryForwardStatus") + .HasColumnType("int"); + + b.Property("CurrentFinancialYearEndDate") + .HasColumnType("datetime2"); + + b.Property("CurrentFinancialYearRevenue") + .HasColumnType("decimal(18,2)"); + + b.Property("CurrentFinancialYearRevenueStatus") + .HasColumnType("int"); + + b.Property("CurrentFinancialYearRevenueStatusExplained") + .HasColumnType("nvarchar(max)"); + + b.Property("CurrentFinancialYearRevenueStatusFileLink") + .HasColumnType("nvarchar(max)"); + + b.Property("DeclarationBodyAgree") + .HasColumnType("bit"); + + b.Property("DeclarationIAmTheChairOrHeadteacher") + .HasColumnType("bit"); + + b.Property("DeclarationSignedByName") + .HasColumnType("nvarchar(max)"); + + b.Property("DioceseFolderIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("DioceseName") + .HasColumnType("nvarchar(max)"); + + b.Property("DynamicsApplyingSchoolId") + .HasColumnType("uniqueidentifier"); + + b.Property("ExemptionEndDate") + .HasColumnType("datetimeoffset"); + + b.Property("FacilitiesShared") + .HasColumnType("bit"); + + b.Property("FacilitiesSharedExplained") + .HasColumnType("nvarchar(max)"); + + b.Property("FinanceOngoingInvestigations") + .HasColumnType("bit"); + + b.Property("FinancialInvestigationsExplain") + .HasColumnType("nvarchar(max)"); + + b.Property("FinancialInvestigationsTrustAware") + .HasColumnType("bit"); + + b.Property("FoundationConsentFolderIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("FoundationTrustOrBodyName") + .HasColumnType("nvarchar(max)"); + + b.Property("FurtherInformation") + .HasColumnType("nvarchar(max)"); + + b.Property("Grants") + .HasColumnType("bit"); + + b.Property("GrantsAwardingBodies") + .HasColumnType("nvarchar(max)"); + + b.Property("HasLeases") + .HasColumnType("bit"); + + b.Property("HasLoans") + .HasColumnType("bit"); + + b.Property("JoinTrustReason") + .HasColumnType("nvarchar(max)"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime2"); + + b.Property("LocalAuthorityClosurePlanDetails") + .HasColumnType("nvarchar(max)"); + + b.Property("LocalAuthorityReoganisationDetails") + .HasColumnType("nvarchar(max)"); + + b.Property("MainContactOtherEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("MainContactOtherName") + .HasColumnType("nvarchar(max)"); + + b.Property("MainContactOtherRole") + .HasColumnType("nvarchar(max)"); + + b.Property("MainContactOtherTelephone") + .HasColumnType("nvarchar(max)"); + + b.Property("MainFeederSchools") + .HasColumnType("nvarchar(max)"); + + b.Property("NextFinancialYearCapitalCarryForward") + .HasColumnType("decimal(18,2)"); + + b.Property("NextFinancialYearCapitalCarryForwardExplained") + .HasColumnType("nvarchar(max)"); + + b.Property("NextFinancialYearCapitalCarryForwardFileLink") + .HasColumnType("nvarchar(max)"); + + b.Property("NextFinancialYearCapitalCarryForwardStatus") + .HasColumnType("int"); + + b.Property("NextFinancialYearEndDate") + .HasColumnType("datetime2"); + + b.Property("NextFinancialYearRevenue") + .HasColumnType("decimal(18,2)"); + + b.Property("NextFinancialYearRevenueStatus") + .HasColumnType("int"); + + b.Property("NextFinancialYearRevenueStatusExplained") + .HasColumnType("nvarchar(max)"); + + b.Property("NextFinancialYearRevenueStatusFileLink") + .HasColumnType("nvarchar(max)"); + + b.Property("OfstedInspectionDetails") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerExplained") + .HasColumnType("nvarchar(max)"); + + b.Property("PartOfBuildingSchoolsForFutureProgramme") + .HasColumnType("bit"); + + b.Property("PartOfFederation") + .HasColumnType("bit"); + + b.Property("PartOfPfiScheme") + .HasColumnType("bit"); + + b.Property("PartOfPfiSchemeType") + .HasColumnType("nvarchar(max)"); + + b.Property("PartOfPrioritySchoolsBuildingProgramme") + .HasColumnType("bit"); + + b.Property("PreviousFinancialYearCapitalCarryForward") + .HasColumnType("decimal(18,2)"); + + b.Property("PreviousFinancialYearCapitalCarryForwardExplained") + .HasColumnType("nvarchar(max)"); + + b.Property("PreviousFinancialYearCapitalCarryForwardFileLink") + .HasColumnType("nvarchar(max)"); + + b.Property("PreviousFinancialYearCapitalCarryForwardStatus") + .HasColumnType("int"); + + b.Property("PreviousFinancialYearEndDate") + .HasColumnType("datetime2"); + + b.Property("PreviousFinancialYearRevenue") + .HasColumnType("decimal(18,2)"); + + b.Property("PreviousFinancialYearRevenueStatus") + .HasColumnType("int"); + + b.Property("PreviousFinancialYearRevenueStatusExplained") + .HasColumnType("nvarchar(max)"); + + b.Property("PreviousFinancialYearRevenueStatusFileLink") + .HasColumnType("nvarchar(max)"); + + b.Property("ProjectedPupilNumbersYear1") + .HasColumnType("int"); + + b.Property("ProjectedPupilNumbersYear2") + .HasColumnType("int"); + + b.Property("ProjectedPupilNumbersYear3") + .HasColumnType("int"); + + b.Property("ProposedNewSchoolName") + .HasColumnType("nvarchar(max)"); + + b.Property("ProtectedCharacteristics") + .HasColumnType("int"); + + b.Property("ResolutionConsentFolderIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("SafeguardingDetails") + .HasColumnType("nvarchar(max)"); + + b.Property("SchoolConversionReasonsForJoining") + .HasColumnType("nvarchar(max)"); + + b.Property("SchoolHasConsultedStakeholders") + .HasColumnType("bit"); + + b.Property("SchoolName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SchoolPlanToConsultStakeholders") + .HasColumnType("nvarchar(max)"); + + b.Property("SupportGrantFundsPaidTo") + .HasColumnType("int"); + + b.Property("TrustBenefitDetails") + .HasColumnType("nvarchar(max)"); + + b.Property("Urn") + .HasColumnType("int"); + + b.Property("WorksPlanned") + .HasColumnType("bit"); + + b.Property("WorksPlannedDate") + .HasColumnType("datetime2"); + + b.Property("WorksPlannedExplained") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ConversionApplicationId"); + + b.ToTable("ApplicationSchool", "academisation"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ApplicationAggregate.ApplicationState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ApplicationReference") + .HasColumnType("nvarchar(max)"); + + b.Property("ApplicationStatus") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ApplicationSubmittedDate") + .HasColumnType("datetime2"); + + b.Property("ApplicationType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("DynamicsApplicationId") + .HasColumnType("uniqueidentifier"); + + b.Property("FormTrustId") + .HasColumnType("int"); + + b.Property("JoinTrustId") + .HasColumnType("int"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("FormTrustId"); + + b.HasIndex("JoinTrustId"); + + b.ToTable("ConversionApplication", "academisation"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ApplicationAggregate.ContributorState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ConversionApplicationId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime2"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OtherRoleName") + .HasColumnType("nvarchar(max)"); + + b.Property("Role") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ConversionApplicationId"); + + b.ToTable("ConversionApplicationContributor", "academisation"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ApplicationAggregate.FormTrustState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + 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("LastModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TrustApproverEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("TrustApproverName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("ApplicationFormTrust", "academisation"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ApplicationAggregate.JoinTrustState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ChangesToLaGovernance") + .HasColumnType("bit"); + + b.Property("ChangesToLaGovernanceExplained") + .HasColumnType("nvarchar(max)"); + + b.Property("ChangesToTrust") + .HasColumnType("int"); + + b.Property("ChangesToTrustExplained") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TrustName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UKPRN") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("ApplicationJoinTrust", "academisation"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ApplicationAggregate.LeaseState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ApplicationSchoolId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("DynamicsSchoolLeaseId") + .HasColumnType("uniqueidentifier"); + + b.Property("InterestRate") + .HasColumnType("decimal(18,2)"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime2"); + + b.Property("LeaseTerm") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PaymentsToDate") + .HasColumnType("decimal(18,2)"); + + b.Property("Purpose") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RepaymentAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("ResponsibleForAssets") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValueOfAssets") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationSchoolId"); + + b.ToTable("ApplicationSchoolLease", "academisation"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ApplicationAggregate.LoanState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("ApplicationSchoolId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("DynamicsSchoolLoanId") + .HasColumnType("uniqueidentifier"); + + b.Property("InterestRate") + .HasColumnType("decimal(18,2)"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Provider") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Purpose") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Schedule") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationSchoolId"); + + b.ToTable("ApplicationSchoolLoan", "academisation"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ApplicationAggregate.TrustKeyPersonState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ApplicationFormTrustId") + .HasColumnType("int"); + + b.Property("Biography") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ContactEmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("DateOfBirth") + .HasColumnType("datetime2"); + + b.Property("DynamicsKeyPersonId") + .HasColumnType("uniqueidentifier"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Role") + .HasColumnType("int"); + + b.Property("Surname") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TimeInRole") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationFormTrustId"); + + b.ToTable("ApplicationFormTrustKeyPerson", "academisation"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ConversionAdvisoryBoardDecisionAggregate.ConversionAdvisoryBoardDecisionDeclinedReasonState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AdvisoryBoardDecisionId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Details") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Reason") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("AdvisoryBoardDecisionId"); + + b.ToTable("ConversionAdvisoryBoardDecisionDeclinedReason", "academisation"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ConversionAdvisoryBoardDecisionAggregate.ConversionAdvisoryBoardDecisionDeferredReasonState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AdvisoryBoardDecisionId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Details") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Reason") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("AdvisoryBoardDecisionId"); + + b.ToTable("ConversionAdvisoryBoardDecisionDeferredReason", "academisation"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ConversionAdvisoryBoardDecisionAggregate.ConversionAdvisoryBoardDecisionState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AdvisoryBoardDecisionDate") + .HasColumnType("datetime2"); + + b.Property("ApprovedConditionsDetails") + .HasColumnType("nvarchar(max)"); + + b.Property("ApprovedConditionsSet") + .HasColumnType("bit"); + + b.Property("ConversionProjectId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Decision") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DecisionMadeBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("ConversionAdvisoryBoardDecision", "academisation"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ProjectAggregate.ProjectState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AcademyOrderRequired") + .HasColumnType("nvarchar(max)"); + + b.Property("AcademyTypeAndRoute") + .HasColumnType("nvarchar(max)"); + + b.Property("ActualPupilNumbers") + .HasColumnType("int"); + + b.Property("AgeRange") + .HasColumnType("nvarchar(max)"); + + b.Property("ApplicationReceivedDate") + .HasColumnType("datetime2"); + + b.Property("ApplicationReferenceNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("AssignedDate") + .HasColumnType("datetime2"); + + 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("BaselineDate") + .HasColumnType("datetime2"); + + b.Property("Capacity") + .HasColumnType("int"); + + b.Property("CapitalCarryForwardAtEndMarchCurrentYear") + .HasColumnType("decimal(18,2)"); + + b.Property("CapitalCarryForwardAtEndMarchNextYear") + .HasColumnType("decimal(18,2)"); + + b.Property("ClearedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Consultation") + .HasColumnType("nvarchar(max)"); + + b.Property("ConversionSupportGrantAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("ConversionSupportGrantChangeReason") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("DiocesanConsent") + .HasColumnType("nvarchar(max)"); + + b.Property("DiocesanTrust") + .HasColumnType("nvarchar(max)"); + + b.Property("DistanceFromSchoolToTrustHeadquarters") + .HasColumnType("decimal(18,2)"); + + b.Property("DistanceFromSchoolToTrustHeadquartersAdditionalInformation") + .HasColumnType("nvarchar(max)"); + + b.Property("EndOfCurrentFinancialYear") + .HasColumnType("datetime2"); + + b.Property("EndOfNextFinancialYear") + .HasColumnType("datetime2"); + + b.Property("EqualitiesImpactAssessmentConsidered") + .HasColumnType("nvarchar(max)"); + + b.Property("FinancialDeficit") + .HasColumnType("nvarchar(max)"); + + b.Property("FoundationConsent") + .HasColumnType("nvarchar(max)"); + + b.Property("GeneralInformationSectionComplete") + .HasColumnType("bit"); + + b.Property("GoverningBodyResolution") + .HasColumnType("nvarchar(max)"); + + b.Property("HeadTeacherBoardDate") + .HasColumnType("datetime2"); + + b.Property("IfdPipelineId") + .HasColumnType("int"); + + b.Property("KeyStage2PerformanceAdditionalInformation") + .HasColumnType("nvarchar(max)"); + + b.Property("KeyStage4PerformanceAdditionalInformation") + .HasColumnType("nvarchar(max)"); + + b.Property("KeyStage5PerformanceAdditionalInformation") + .HasColumnType("nvarchar(max)"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime2"); + + b.Property("LegalRequirementsSectionComplete") + .HasColumnType("bit"); + + b.Property("LocalAuthority") + .HasColumnType("nvarchar(max)"); + + b.Property("LocalAuthorityInformationTemplateComments") + .HasColumnType("nvarchar(max)"); + + b.Property("LocalAuthorityInformationTemplateLink") + .HasColumnType("nvarchar(max)"); + + b.Property("LocalAuthorityInformationTemplateReturnedDate") + .HasColumnType("datetime2"); + + b.Property("LocalAuthorityInformationTemplateSectionComplete") + .HasColumnType("bit"); + + b.Property("LocalAuthorityInformationTemplateSentDate") + .HasColumnType("datetime2"); + + b.Property("MemberOfParliamentName") + .HasColumnType("nvarchar(max)"); + + b.Property("MemberOfParliamentParty") + .HasColumnType("nvarchar(max)"); + + b.Property("NameOfTrust") + .HasColumnType("nvarchar(max)"); + + b.Property("OpeningDate") + .HasColumnType("datetime2"); + + b.Property("PartOfPfiScheme") + .HasColumnType("nvarchar(max)"); + + b.Property("PercentageFreeSchoolMeals") + .HasColumnType("decimal(18,2)"); + + b.Property("PercentageOfGoodOrOutstandingSchoolsInTheDiocesanTrust") + .HasColumnType("decimal(18,2)"); + + b.Property("PreviousHeadTeacherBoardDate") + .HasColumnType("datetime2"); + + b.Property("PreviousHeadTeacherBoardDateQuestion") + .HasColumnType("nvarchar(max)"); + + b.Property("PreviousHeadTeacherBoardLink") + .HasColumnType("nvarchar(max)"); + + b.Property("ProjectStatus") + .HasColumnType("nvarchar(max)"); + + b.Property("ProjectedRevenueBalanceAtEndMarchNextYear") + .HasColumnType("decimal(18,2)"); + + b.Property("ProposedAcademyOpeningDate") + .HasColumnType("datetime2"); + + b.Property("PublishedAdmissionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("RationaleForProject") + .HasColumnType("nvarchar(max)"); + + b.Property("RationaleForTrust") + .HasColumnType("nvarchar(max)"); + + b.Property("RationaleSectionComplete") + .HasColumnType("bit"); + + b.Property("RecommendationForProject") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("RevenueCarryForwardAtEndMarchCurrentYear") + .HasColumnType("decimal(18,2)"); + + b.Property("RisksAndIssues") + .HasColumnType("nvarchar(max)"); + + b.Property("RisksAndIssuesSectionComplete") + .HasColumnType("bit"); + + b.Property("SchoolAndTrustInformationSectionComplete") + .HasColumnType("bit"); + + b.Property("SchoolBudgetInformationAdditionalInformation") + .HasColumnType("nvarchar(max)"); + + b.Property("SchoolBudgetInformationSectionComplete") + .HasColumnType("bit"); + + b.Property("SchoolName") + .HasColumnType("nvarchar(max)"); + + b.Property("SchoolPerformanceAdditionalInformation") + .HasColumnType("nvarchar(max)"); + + b.Property("SchoolPhase") + .HasColumnType("nvarchar(max)"); + + b.Property("SchoolPupilForecastsAdditionalInformation") + .HasColumnType("nvarchar(max)"); + + b.Property("SchoolType") + .HasColumnType("nvarchar(max)"); + + b.Property("SponsorName") + .HasColumnType("nvarchar(max)"); + + b.Property("SponsorReferenceNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TrustReferenceNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Urn") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("nvarchar(max)"); + + b.Property("ViabilityIssues") + .HasColumnType("nvarchar(max)"); + + b.Property("YearOneProjectedCapacity") + .HasColumnType("int"); + + b.Property("YearOneProjectedPupilNumbers") + .HasColumnType("int"); + + b.Property("YearThreeProjectedCapacity") + .HasColumnType("int"); + + b.Property("YearThreeProjectedPupilNumbers") + .HasColumnType("int"); + + b.Property("YearTwoProjectedCapacity") + .HasColumnType("int"); + + b.Property("YearTwoProjectedPupilNumbers") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Project", "academisation"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ApplicationAggregate.ApplicationSchoolState", b => + { + b.HasOne("Dfe.Academies.Academisation.Data.ApplicationAggregate.ApplicationState", null) + .WithMany("Schools") + .HasForeignKey("ConversionApplicationId"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ApplicationAggregate.ApplicationState", b => + { + b.HasOne("Dfe.Academies.Academisation.Data.ApplicationAggregate.FormTrustState", "FormTrust") + .WithMany() + .HasForeignKey("FormTrustId"); + + b.HasOne("Dfe.Academies.Academisation.Data.ApplicationAggregate.JoinTrustState", "JoinTrust") + .WithMany() + .HasForeignKey("JoinTrustId"); + + b.Navigation("FormTrust"); + + b.Navigation("JoinTrust"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ApplicationAggregate.ContributorState", b => + { + b.HasOne("Dfe.Academies.Academisation.Data.ApplicationAggregate.ApplicationState", null) + .WithMany("Contributors") + .HasForeignKey("ConversionApplicationId"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ApplicationAggregate.LeaseState", b => + { + b.HasOne("Dfe.Academies.Academisation.Data.ApplicationAggregate.ApplicationSchoolState", null) + .WithMany("Leases") + .HasForeignKey("ApplicationSchoolId"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ApplicationAggregate.LoanState", b => + { + b.HasOne("Dfe.Academies.Academisation.Data.ApplicationAggregate.ApplicationSchoolState", null) + .WithMany("Loans") + .HasForeignKey("ApplicationSchoolId"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ApplicationAggregate.TrustKeyPersonState", b => + { + b.HasOne("Dfe.Academies.Academisation.Data.ApplicationAggregate.FormTrustState", null) + .WithMany("KeyPeople") + .HasForeignKey("ApplicationFormTrustId"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ConversionAdvisoryBoardDecisionAggregate.ConversionAdvisoryBoardDecisionDeclinedReasonState", b => + { + b.HasOne("Dfe.Academies.Academisation.Data.ConversionAdvisoryBoardDecisionAggregate.ConversionAdvisoryBoardDecisionState", null) + .WithMany("DeclinedReasons") + .HasForeignKey("AdvisoryBoardDecisionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ConversionAdvisoryBoardDecisionAggregate.ConversionAdvisoryBoardDecisionDeferredReasonState", b => + { + b.HasOne("Dfe.Academies.Academisation.Data.ConversionAdvisoryBoardDecisionAggregate.ConversionAdvisoryBoardDecisionState", null) + .WithMany("DeferredReasons") + .HasForeignKey("AdvisoryBoardDecisionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ApplicationAggregate.ApplicationSchoolState", b => + { + b.Navigation("Leases"); + + b.Navigation("Loans"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ApplicationAggregate.ApplicationState", b => + { + b.Navigation("Contributors"); + + b.Navigation("Schools"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ApplicationAggregate.FormTrustState", b => + { + b.Navigation("KeyPeople"); + }); + + modelBuilder.Entity("Dfe.Academies.Academisation.Data.ConversionAdvisoryBoardDecisionAggregate.ConversionAdvisoryBoardDecisionState", b => + { + b.Navigation("DeclinedReasons"); + + b.Navigation("DeferredReasons"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Dfe.Academies.Academisation.Data/Migrations/20221205161027_DataConversionColumns.cs b/Dfe.Academies.Academisation.Data/Migrations/20221205161027_DataConversionColumns.cs new file mode 100644 index 000000000..0fd81dbbc --- /dev/null +++ b/Dfe.Academies.Academisation.Data/Migrations/20221205161027_DataConversionColumns.cs @@ -0,0 +1,89 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Dfe.Academies.Academisation.Data.Migrations +{ + public partial class DataConversionColumns : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ApplicationReference", + schema: "academisation", + table: "ConversionApplication", + type: "nvarchar(max)", + nullable: true); + + migrationBuilder.AddColumn( + name: "DynamicsApplicationId", + schema: "academisation", + table: "ConversionApplication", + type: "uniqueidentifier", + nullable: true); + + migrationBuilder.AddColumn( + name: "DynamicsSchoolLoanId", + schema: "academisation", + table: "ApplicationSchoolLoan", + type: "uniqueidentifier", + nullable: true); + + migrationBuilder.AddColumn( + name: "DynamicsSchoolLeaseId", + schema: "academisation", + table: "ApplicationSchoolLease", + type: "uniqueidentifier", + nullable: true); + + migrationBuilder.AddColumn( + name: "DynamicsApplyingSchoolId", + schema: "academisation", + table: "ApplicationSchool", + type: "uniqueidentifier", + nullable: true); + + migrationBuilder.AddColumn( + name: "DynamicsKeyPersonId", + schema: "academisation", + table: "ApplicationFormTrustKeyPerson", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ApplicationReference", + schema: "academisation", + table: "ConversionApplication"); + + migrationBuilder.DropColumn( + name: "DynamicsApplicationId", + schema: "academisation", + table: "ConversionApplication"); + + migrationBuilder.DropColumn( + name: "DynamicsSchoolLoanId", + schema: "academisation", + table: "ApplicationSchoolLoan"); + + migrationBuilder.DropColumn( + name: "DynamicsSchoolLeaseId", + schema: "academisation", + table: "ApplicationSchoolLease"); + + migrationBuilder.DropColumn( + name: "DynamicsApplyingSchoolId", + schema: "academisation", + table: "ApplicationSchool"); + + migrationBuilder.DropColumn( + name: "DynamicsKeyPersonId", + schema: "academisation", + table: "ApplicationFormTrustKeyPerson"); + } + } +} diff --git a/Dfe.Academies.Academisation.Data/Migrations/AcademisationContextModelSnapshot.cs b/Dfe.Academies.Academisation.Data/Migrations/AcademisationContextModelSnapshot.cs index 8efa8c814..429b4153a 100644 --- a/Dfe.Academies.Academisation.Data/Migrations/AcademisationContextModelSnapshot.cs +++ b/Dfe.Academies.Academisation.Data/Migrations/AcademisationContextModelSnapshot.cs @@ -127,6 +127,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DioceseName") .HasColumnType("nvarchar(max)"); + b.Property("DynamicsApplyingSchoolId") + .HasColumnType("uniqueidentifier"); + b.Property("ExemptionEndDate") .HasColumnType("datetimeoffset"); @@ -335,6 +338,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + b.Property("ApplicationReference") + .HasColumnType("nvarchar(max)"); + b.Property("ApplicationStatus") .IsRequired() .HasColumnType("nvarchar(max)"); @@ -349,6 +355,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CreatedOn") .HasColumnType("datetime2"); + b.Property("DynamicsApplicationId") + .HasColumnType("uniqueidentifier"); + b.Property("FormTrustId") .HasColumnType("int"); @@ -531,6 +540,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CreatedOn") .HasColumnType("datetime2"); + b.Property("DynamicsSchoolLeaseId") + .HasColumnType("uniqueidentifier"); + b.Property("InterestRate") .HasColumnType("decimal(18,2)"); @@ -583,6 +595,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CreatedOn") .HasColumnType("datetime2"); + b.Property("DynamicsSchoolLoanId") + .HasColumnType("uniqueidentifier"); + b.Property("InterestRate") .HasColumnType("decimal(18,2)"); @@ -632,6 +647,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DateOfBirth") .HasColumnType("datetime2"); + b.Property("DynamicsKeyPersonId") + .HasColumnType("uniqueidentifier"); + b.Property("FirstName") .IsRequired() .HasColumnType("nvarchar(max)"); diff --git a/Dfe.Academies.Academisation.Domain/ApplicationAggregate/Application.cs b/Dfe.Academies.Academisation.Domain/ApplicationAggregate/Application.cs index 70f1acba3..3bcf9ec30 100644 --- a/Dfe.Academies.Academisation.Domain/ApplicationAggregate/Application.cs +++ b/Dfe.Academies.Academisation.Domain/ApplicationAggregate/Application.cs @@ -1,7 +1,5 @@ -using System.Data; -using Dfe.Academies.Academisation.Core; +using Dfe.Academies.Academisation.Core; using Dfe.Academies.Academisation.Domain.ApplicationAggregate.Schools; -using Dfe.Academies.Academisation.Domain.ApplicationAggregate.Trusts; using Dfe.Academies.Academisation.Domain.Core.ApplicationAggregate; using Dfe.Academies.Academisation.Domain.SeedWork; using Dfe.Academies.Academisation.Domain.Validations; @@ -35,7 +33,8 @@ public Application( IEnumerable schools, IJoinTrust? joinTrust, IFormTrust? formTrust, - DateTime? applicationSubmittedOn = null) + DateTime? applicationSubmittedOn = null, + string? applicationReference = null) { ApplicationId = applicationId; CreatedOn = createdOn; @@ -47,6 +46,7 @@ public Application( JoinTrust = joinTrust; FormTrust = formTrust; ApplicationSubmittedDate = applicationSubmittedOn; + ApplicationReference = applicationReference; } public int ApplicationId { get; private set; } @@ -68,6 +68,12 @@ public void SetIdsOnCreate(int applicationId, int contributorId) _contributors.Single().Id = contributorId; } + /// + /// This is in the format $"A2B_{ApplicationId}" + /// Currently calculated by new UI but we need somewhere to store existing data from dynamics + /// + public string? ApplicationReference { get; set; } + public CommandResult Update( ApplicationType applicationType, ApplicationStatus applicationStatus, diff --git a/Dfe.Academies.Academisation.IDomain/ApplicationAggregate/IApplication.cs b/Dfe.Academies.Academisation.IDomain/ApplicationAggregate/IApplication.cs index 8ad0c71f2..413d4bb0d 100644 --- a/Dfe.Academies.Academisation.IDomain/ApplicationAggregate/IApplication.cs +++ b/Dfe.Academies.Academisation.IDomain/ApplicationAggregate/IApplication.cs @@ -21,6 +21,12 @@ public interface IApplication DateTime? ApplicationSubmittedDate { get; } void SetIdsOnCreate(int applicationId, int conversionId); + /// + /// This is in the format $"A2B_{ApplicationId}" + /// Currently calculated by new UI but we need somewhere to store existing data from dynamics + /// + string? ApplicationReference { get; set; } + CommandResult Update( ApplicationType applicationType, ApplicationStatus applicationStatus, diff --git a/Dfe.Academies.Academisation.IService/ServiceModels/Application/ApplicationServiceModel.cs b/Dfe.Academies.Academisation.IService/ServiceModels/Application/ApplicationServiceModel.cs index 694fa3c8a..35ae84aba 100644 --- a/Dfe.Academies.Academisation.IService/ServiceModels/Application/ApplicationServiceModel.cs +++ b/Dfe.Academies.Academisation.IService/ServiceModels/Application/ApplicationServiceModel.cs @@ -10,4 +10,5 @@ public record ApplicationServiceModel( IReadOnlyCollection Schools, ApplicationJoinTrustServiceModel? joinTrustDetails, ApplicationFormTrustServiceModel? formTrustDetails, - DateTime? ApplicationSubmittedDate); + DateTime? ApplicationSubmittedDate, + string? ApplicationReference); diff --git a/Dfe.Academies.Academisation.Service/Mappers/Application/ApplicationServiceModelMapper.cs b/Dfe.Academies.Academisation.Service/Mappers/Application/ApplicationServiceModelMapper.cs index 2de1dbec6..f51fbba0f 100644 --- a/Dfe.Academies.Academisation.Service/Mappers/Application/ApplicationServiceModelMapper.cs +++ b/Dfe.Academies.Academisation.Service/Mappers/Application/ApplicationServiceModelMapper.cs @@ -18,6 +18,7 @@ internal static ApplicationServiceModel MapFromDomain(this IApplication applicat .Select(ApplicationSchoolServiceModelMapper.FromDomain).ToList(), mapper.Map(application.JoinTrust), mapper.Map(application.FormTrust), - application.ApplicationSubmittedDate); + application.ApplicationSubmittedDate, + application.ApplicationReference); } } diff --git a/Dfe.Academies.Academisation.SubcutaneousTest/ApplicationAggregate/ApplicationCreateTests.cs b/Dfe.Academies.Academisation.SubcutaneousTest/ApplicationAggregate/ApplicationCreateTests.cs index bc939ea73..b613bac8f 100644 --- a/Dfe.Academies.Academisation.SubcutaneousTest/ApplicationAggregate/ApplicationCreateTests.cs +++ b/Dfe.Academies.Academisation.SubcutaneousTest/ApplicationAggregate/ApplicationCreateTests.cs @@ -106,7 +106,7 @@ public async Task ParametersValid___ApplicationCreated() applicationCreateRequestModel.Contributor.Role, applicationCreateRequestModel.Contributor.OtherRoleName) }, new List(), - null, null, null); + null, null, null, null); Assert.Equivalent(expectedApplication, actualApplication); }