Skip to content

Commit

Permalink
make incomingTrustName nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
elielijah321 committed Apr 15, 2024
1 parent 6d39420 commit f2e04a9
Show file tree
Hide file tree
Showing 8 changed files with 2,053 additions and 17 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Dfe.Academies.Academisation.Data.Migrations
{
/// <inheritdoc />
public partial class nullableIncomingTrustName : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "IncomingTrustName",
schema: "academisation",
table: "TransferringAcademy",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "IncomingTrustName",
schema: "academisation",
table: "TransferringAcademy",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));

b.Property<string>("IncomingTrustName")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("IncomingTrustUkprn")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private static TransferProject CreateValidTransferProject()

[Theory]
[ClassData(typeof(CreationArgumentExceptionTestData))]
public void CreateTransferProject_WithTestData_ThrowsArgumentExceptions(string outgoingTrustUkprn, string outgoingTrustName, string incomingTrustUkprn, string incomingTrustName, List<string> academyUkprns, DateTime createdOn, Type exType)
public void CreateTransferProject_WithTestData_ThrowsArgumentExceptions(string outgoingTrustUkprn, string outgoingTrustName, string? incomingTrustUkprn, string? incomingTrustName, List<string> academyUkprns, DateTime createdOn, Type exType)
{
// Arrange
dynamic exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Dfe.Academies.Academisation.Domain.TransferProjectAggregate
{
public class TransferProject : ITransferProject, IAggregateRoot
{
private TransferProject(string outgoingTrustUkprn, string outgoingTrustName, string? incomingTrustUkprn, string incomingTrustName, List<string> academyUkprns)
private TransferProject(string outgoingTrustUkprn, string outgoingTrustName, string? incomingTrustUkprn, string? incomingTrustName, List<string> academyUkprns)
{
_intendedTransferBenefits =
new List<IntendedTransferBenefit>();
Expand Down Expand Up @@ -196,11 +196,11 @@ public void SetStatus(string status)
Status = status;
}

public static TransferProject Create(string outgoingTrustUkprn, string outgoingTrustName, string? incomingTrustUkprn, string incomingTrustName, List<string> academyUkprns, DateTime createdOn)
public static TransferProject Create(string outgoingTrustUkprn, string outgoingTrustName, string? incomingTrustUkprn, string? incomingTrustName, List<string> academyUkprns, DateTime createdOn)
{
Guard.Against.NullOrEmpty(outgoingTrustUkprn);
Guard.Against.NullOrEmpty(outgoingTrustName);
Guard.Against.NullOrEmpty(incomingTrustName);
//Guard.Against.NullOrEmpty(incomingTrustName);
Guard.Against.NullOrEmpty(academyUkprns);
Guard.Against.OutOfSQLDateRange(createdOn);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Dfe.Academies.Academisation.Domain.TransferProjectAggregate
{
public class TransferringAcademy : ITransferringAcademy
{
public TransferringAcademy(string? incomingTrustUkprn, string incomingTrustName, string outgoingAcademyUkprn)
public TransferringAcademy(string? incomingTrustUkprn, string? incomingTrustName, string outgoingAcademyUkprn)
{
IncomingTrustUkprn = incomingTrustUkprn;
IncomingTrustName = incomingTrustName;
Expand All @@ -21,7 +21,7 @@ public TransferringAcademy(string? incomingTrustUkprn, string incomingTrustName,
public int TransferProjectId { get; private set; }
public string OutgoingAcademyUkprn { get; private set; }
public string? IncomingTrustUkprn { get; private set; }
public string IncomingTrustName { get; private set; }
public string? IncomingTrustName { get; private set; }

public string? PupilNumbersAdditionalInformation { get; private set; }
public string? LatestOfstedReportAdditionalInformation { get; private set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Dfe.Academies.Academisation.Service.Commands.TransferProject;
public class CreateTransferProjectCommand : IRequest<CreateResult>
{

public CreateTransferProjectCommand(string outgoingTrustUkprn, string outgoingTrustName, string? incomingTrustUkprn, string incomingTrustName, List<string> transferringAcademyUkprns)
public CreateTransferProjectCommand(string outgoingTrustUkprn, string outgoingTrustName, string? incomingTrustUkprn, string? incomingTrustName, List<string> transferringAcademyUkprns)
{
OutgoingTrustUkprn = outgoingTrustUkprn;
OutgoingTrustName = outgoingTrustName;
Expand All @@ -19,5 +19,5 @@ public CreateTransferProjectCommand(string outgoingTrustUkprn, string outgoingTr
public string OutgoingTrustUkprn { get; set; }
public string? IncomingTrustUkprn { get; set; }
public string OutgoingTrustName { get; set; }
public string IncomingTrustName { get; set; }
public string? IncomingTrustName { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@ public async Task<PagedResultResponse<AcademyTransferProjectSummaryResponse>> Ge
IEnumerable<AcademyTransferProjectSummaryResponse> projects =
FilterByIncomingTrust(title, AcademyTransferProjectSummaryResponse(transferProjects));

// remove any projects without an incoming or outgoing trust.
// remove any projects without an outgoing trust.
projects = projects
.Where(p =>
!string.IsNullOrEmpty(p.OutgoingTrustUkprn) && !string.IsNullOrEmpty(p.OutgoingTrustName) &&
// just filtered out by incoming trust name now to allow for form a mat
!p.TransferringAcademies.Any(ta => string.IsNullOrEmpty(ta.IncomingTrustName))).ToList();
!string.IsNullOrEmpty(p.OutgoingTrustUkprn) && !string.IsNullOrEmpty(p.OutgoingTrustName)
).ToList();

var recordTotal = projects.Count();

Expand All @@ -70,12 +69,10 @@ public async Task<PagedResultResponse<ExportedTransferProjectModel>> GetExported
transferProjects =
FilterExportedTransferProjectsByIncomingTrust(title, transferProjects);

// remove any projects without an incoming or outgoing trust.
// remove any projects without an outgoing trust.
transferProjects = transferProjects
.Where(p =>
!string.IsNullOrEmpty(p.OutgoingTrustUkprn) && !string.IsNullOrEmpty(p.OutgoingTrustName) &&
// just filtered out by incoming trust name now to allow for form a mat
!p.TransferringAcademies.Any(ta => string.IsNullOrEmpty(ta.IncomingTrustName))).ToList();
!string.IsNullOrEmpty(p.OutgoingTrustUkprn) && !string.IsNullOrEmpty(p.OutgoingTrustName)).ToList();

var projects = await MapExportedTransferProjectModel(transferProjects);

Expand Down

0 comments on commit f2e04a9

Please sign in to comment.