Skip to content

Commit

Permalink
Merge pull request #1092 from DFE-Digital/feature/169468-amend-adviso…
Browse files Browse the repository at this point in the history
…ry-board-date

advisory board dates
  • Loading branch information
elielijah321 authored Jul 3, 2024
2 parents 5a58aa8 + 5c98a81 commit 594985a
Show file tree
Hide file tree
Showing 46 changed files with 1,214 additions and 710 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,4 @@
<PackageReference Include="System.Net.Http.Json" Version="7.0.1" />
</ItemGroup>

<ItemGroup>
<Folder Include="Models\AcademyConversion\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,27 @@ public async Task<HttpResponseMessage> SetFormAMatProjectReference(int id, SetFo
{
return await AcademisationClient.PutAsync(string.Format(PathFor.SetFormAMatProjectReference, id), JsonContent.Create(setFormAMatProjectReference));
}

public async Task<HttpResponseMessage> SetProjectDates(int id, SetProjectDatesModel updatedProjectDates)
{
var payload = new
{
id = updatedProjectDates.Id,
advisoryBoardDate = updatedProjectDates.AdvisoryBoardDate ?? null,
previousAdvisoryBoard = updatedProjectDates.PreviousAdvisoryBoard ?? null,
proposedConversionDate = updatedProjectDates.ProposedConversionDate ?? null,
projectDatesSectionComplete = updatedProjectDates.ProjectDatesSectionComplete ?? null,
changedBy = updatedProjectDates.ChangedBy ?? null,
reasonsChanged = updatedProjectDates.ReasonsChanged ?? null,
};

var formattedString = string.Format(PathFor.SetProjectDates, id);
return await AcademisationClient.PutAsync(formattedString, JsonContent.Create(payload));
}

public async Task<HttpResponseMessage> GetOpeningDateHistoryForConversionProject(int id)
{
HttpResponseMessage getHistoryResponse = await AcademisationClient.GetAsync(string.Format(PathFor.GetOpeningDateHistoryForConversionProject, id));
return getHistoryResponse;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ public interface IApiClient
Task<HttpResponseMessage> GetFormAMatProjectsAsync(AcademyConversionSearchModelV2 searchModel);
Task<HttpResponseMessage> SearchFormAMatProjects(string searchTerm);
Task<HttpResponseMessage> SetFormAMatProjectReference(int id, SetFormAMatProjectReference setFormAMatProjectReference);
Task<HttpResponseMessage> SetProjectDates(int id, SetProjectDatesModel updatedProjectDates);
Task<HttpResponseMessage> GetOpeningDateHistoryForConversionProject(int id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ public PathFor(IFeatureManager features)
public static string GetFormAMatProjects => "/conversion-project/FormAMatProjects";
public static string SearchFormAMatProjects => "/conversion-project/search-formamatprojects";
public static string SetFormAMatProjectReference => "/conversion-project/{0}/SetFormAMatProjectReference";

public static string SetProjectDates => "/conversion-project/{0}/SetProjectDates";
public static string GetOpeningDateHistoryForConversionProject => "/conversion-project/{0}/conversion-date-history";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.ComponentModel;

namespace Dfe.PrepareConversions.Data.Models.AcademyConversion;

public enum ConversionDateReasonForChangeFuture
{
[Description("Incoming trust")] IncomingTrust = 1,
[Description("School")] School = 2,
[Description("LA (local authority)")] LA = 3,
[Description("Diocese")] Diocese = 4,
[Description("TuPE (Transfer of Undertakings Protection of Employments rights)")] TuPE = 5,
[Description("Pensions")] Pensions = 6,
[Description("Union")] Union = 7,
[Description("Negative press coverage")] NegativePressCoverage = 8,
[Description("Governance")] Governance = 9,
[Description("Finance")] Finance = 10,
[Description("Viability")] Viability = 11,
[Description("Land")] Land = 12,
[Description("Buildings")] Buildings = 13,
[Description("Legal documents")] LegalDocuments = 14,
[Description("Correcting an error")] CorrectingAnError = 15,
[Description("Voluntary deferral")] VoluntaryDeferral = 16,
[Description("In a federation")] InAFederation = 17,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.ComponentModel;

namespace Dfe.PrepareConversions.Data.Models.AcademyConversion;

public enum ConversionDateReasonForChangePast
{
[Description("Conversion is progressing faster than expected")] ProgressingFaster = 1,
[Description("Correcting an error")] CorrectingAnError = 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,9 @@ public class AcademyConversionProject
// notes
public ICollection<ProjectNote> Notes { get; set; } = new List<ProjectNote>();

//Project Dates
public DateTime? ProposedConversionDate { get; set; }

public bool ProjectDatesSectionComplete { get; set; }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dfe.PrepareConversions.Data.Models
{
public class OpeningDateHistoryDto
{
public DateTime ChangedAt { get; set; }
public string ChangedBy { get; set; }
public DateTime? OldDate { get; set; }
public DateTime? NewDate { get; set; }
public List<ReasonChange> ReasonsChanged { get; set; }
}


public class ReasonChange
{
public ReasonChange(string heading, string details)
{
Heading = heading;
Details = details;
}

public string Heading { get; set; }
public string Details { get; set; }

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;

namespace Dfe.PrepareConversions.Data.Models
{
public class SetProjectDatesModel
{
public int Id { get; set; }
public DateTime? AdvisoryBoardDate { get; set; }
public DateTime? PreviousAdvisoryBoard { get; set; }
public DateTime? ProposedConversionDate { get; set; }
public bool? ProjectDatesSectionComplete { get; set; }
public IEnumerable<ReasonChange>? ReasonsChanged { get; set; }
public string? ChangedBy { get; set; }

public SetProjectDatesModel() { }

public SetProjectDatesModel(int id, DateTime? advisoryBoardDate, DateTime? previousAdvisoryBoard, DateTime? proposedConversionDate, bool? projectDatesSectionComplete, string? changedBy = default, IEnumerable<ReasonChange>? reasonsChanged = default)
{
Id = id;
AdvisoryBoardDate = advisoryBoardDate;
PreviousAdvisoryBoard = previousAdvisoryBoard;
ProposedConversionDate = proposedConversionDate;
ProjectDatesSectionComplete = projectDatesSectionComplete;
ChangedBy = changedBy;
ReasonsChanged = reasonsChanged;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -375,4 +375,23 @@ public async Task UpdateSchoolImprovementPlan(int id, UpdateSchoolImprovementPla

if (!result.Success) throw new ApiResponseException($"Request to Api failed | StatusCode - {result.StatusCode}");
}

public async Task SetProjectDates(int id, SetProjectDatesModel updatedProjectDates)
{
HttpResponseMessage result = await _apiClient.SetProjectDates(id, updatedProjectDates);
if (result.IsSuccessStatusCode is false) throw new ApiResponseException($"Request to Api failed | StatusCode - {result.StatusCode}");
}

public async Task<ApiResponse<IEnumerable<OpeningDateHistoryDto>>> GetOpeningDateHistoryForConversionProject(int id)
{
HttpResponseMessage response = await _apiClient.GetOpeningDateHistoryForConversionProject(id);
if (!response.IsSuccessStatusCode)
{
return new ApiResponse<IEnumerable<OpeningDateHistoryDto>>(response.StatusCode, null);
}

IEnumerable<OpeningDateHistoryDto> history = await ReadFromJsonAndThrowIfNull<IEnumerable<OpeningDateHistoryDto>>(response.Content);
return new ApiResponse<IEnumerable<OpeningDateHistoryDto>>(response.StatusCode, history);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,6 @@ Task<ApiResponse<ApiV2Wrapper<IEnumerable<FormAMatProject>>>> GetFormAMatProject

Task<ApiResponse<IEnumerable<SchoolImprovementPlan>>> GetSchoolImprovementPlansForProject(int id);
Task UpdateSchoolImprovementPlan(int id, UpdateSchoolImprovementPlan updateSchoolImprovementPlan);
Task SetProjectDates(int id, SetProjectDatesModel updatedProjectDates);
Task<ApiResponse<IEnumerable<OpeningDateHistoryDto>>> GetOpeningDateHistoryForConversionProject(int id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public async Task Should_Display_About_The_Conversion_Section(string path)
Document.QuerySelectorAll("h2").Where(contents => contents.InnerHtml == "About the conversion").Should().NotBeEmpty();
Document.QuerySelectorAll("h3").Where(contents => contents.InnerHtml == "The school joining the trust").Should().NotBeEmpty();
Document.QuerySelectorAll("h3").Where(contents => contents.InnerHtml == "Contact details").Should().NotBeEmpty();
Document.QuerySelectorAll("h3").Where(contents => contents.InnerHtml == "Date for conversion").Should().NotBeEmpty();
Document.QuerySelectorAll("h3").Where(contents => contents.InnerHtml == "Reasons for joining").Should().NotBeEmpty();
Document.QuerySelectorAll("h3").Where(contents => contents.InnerHtml == "Name changes").Should().NotBeEmpty();
}
Expand Down
Loading

0 comments on commit 594985a

Please sign in to comment.