diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Dfe.PrepareConversions.Data.Tests.csproj b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Dfe.PrepareConversions.Data.Tests.csproj index 47d28666c..731900e01 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Dfe.PrepareConversions.Data.Tests.csproj +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Dfe.PrepareConversions.Data.Tests.csproj @@ -9,7 +9,7 @@ - + diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Dfe.PrepareConversions.Data.csproj b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Dfe.PrepareConversions.Data.csproj index 5d96222ec..6a3dfdf30 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Dfe.PrepareConversions.Data.csproj +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Dfe.PrepareConversions.Data.csproj @@ -11,7 +11,7 @@ - + diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/ApiClient.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/ApiClient.cs index 7bd02a7a4..b180371ab 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/ApiClient.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/ApiClient.cs @@ -1,6 +1,7 @@ using Dfe.PrepareConversions.Data.Models; using Dfe.PrepareConversions.Data.Services; using Microsoft.FeatureManagement; +using System.Dynamic; using System.Net.Http; using System.Net.Http.Json; using System.Threading.Tasks; @@ -55,4 +56,15 @@ public async Task AddProjectNote(int id, AddProjectNote pro { return await AcademisationClient.PostAsync(string.Format(PathFor.AddProjectNote, id), JsonContent.Create(projectNote)); } + + public async Task SetProjectExternalApplicationForm(int id, bool externalApplicationFormSaved, string externalApplicationFormUrl) + { + var payload = new + { + externalApplicationFormSaved = externalApplicationFormSaved, + externalApplicationFormUrl = externalApplicationFormUrl ?? string.Empty + }; + + return await AcademisationClient.PutAsync(string.Format(PathFor.SetExternalApplicationForm, id), JsonContent.Create(payload)); + } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/IApiClient.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/IApiClient.cs index d3bd46693..d3f8d422c 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/IApiClient.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/IApiClient.cs @@ -12,4 +12,6 @@ public interface IApiClient Task GetFilterParametersAsync(); Task GetApplicationByReferenceAsync(string id); Task AddProjectNote(int id, AddProjectNote projectNote); + + Task SetProjectExternalApplicationForm(int id, bool externalApplicationFormSaved, string externalApplicationFormUrl); } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/PathFor.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/PathFor.cs index 57679fc85..574aa8dd2 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/PathFor.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/PathFor.cs @@ -16,4 +16,5 @@ public PathFor(IFeatureManager features) public static string UpdateProject => "/legacy/project/{0}"; public static string GetFilterParameters => "/legacy/projects/status"; public static string AddProjectNote => "/legacy/project/{0}/notes"; + public static string SetExternalApplicationForm => "/conversion-project/{0}/setExternalApplicationForm"; } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs index 493f4e912..2cc9d77e9 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs @@ -54,6 +54,10 @@ public class AcademyConversionProject public bool? AnnexBFormReceived { get; set; } public string AnnexBFormUrl { get; set; } + // External Application Form + public bool? ExternalApplicationFormSaved { get; set; } + public string? ExternalApplicationFormUrl { get; set; } + // School Overview public string PublishedAdmissionNumber { get; set; } public string PartOfPfiScheme { get; set; } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/UpdateAcademyConversionProject.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/UpdateAcademyConversionProject.cs index 766923aa7..7d30b7e90 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/UpdateAcademyConversionProject.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/UpdateAcademyConversionProject.cs @@ -53,6 +53,10 @@ public class UpdateAcademyConversionProject public bool? AnnexBFormReceived { get; set; } public string AnnexBFormUrl { get; set; } + // External Application Form + public bool? ExternalApplicationFormSaved { get; set; } + public string ExternalApplicationFormUrl { get; set; } + //school performance ofsted information public string SchoolPerformanceAdditionalInformation { get; set; } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/AcademyConversionProjectRepository.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/AcademyConversionProjectRepository.cs index 696da5d10..23c72be82 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/AcademyConversionProjectRepository.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/AcademyConversionProjectRepository.cs @@ -171,4 +171,10 @@ private async Task ReadFromJsonAndThrowIfNull(HttpContent content) } return responseObj; } + + public async Task SetProjectExternalApplicationForm(int id, bool externalApplicationFormSaved, string externalApplicationFormUrl) + { + HttpResponseMessage result = await _apiClient.SetProjectExternalApplicationForm(id, externalApplicationFormSaved, externalApplicationFormUrl); + if (result.IsSuccessStatusCode is false) throw new ApiResponseException($"Request to Api failed | StatusCode - {result.StatusCode}"); + } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IAcademyConversionProjectRepository.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IAcademyConversionProjectRepository.cs index 90edc53bc..c40a18ae7 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IAcademyConversionProjectRepository.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IAcademyConversionProjectRepository.cs @@ -20,6 +20,7 @@ Task>>> GetAllPro Task> GetProjectById(int id); Task> UpdateProject(int id, UpdateAcademyConversionProject updateProject); Task CreateProject(CreateNewProject newProject); + Task SetProjectExternalApplicationForm(int id, bool externalApplicationFormSaved, string externalApplicationFormUrl); Task> GetFilterParameters(); Task> AddProjectNote(int id, AddProjectNote addProjectNote); } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.DocumentGeneration.Tests/Dfe.PrepareConversions.DocumentGeneration.Tests.csproj b/Dfe.PrepareConversions/Dfe.PrepareConversions.DocumentGeneration.Tests/Dfe.PrepareConversions.DocumentGeneration.Tests.csproj index d275087e2..db5f11e07 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.DocumentGeneration.Tests/Dfe.PrepareConversions.DocumentGeneration.Tests.csproj +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.DocumentGeneration.Tests/Dfe.PrepareConversions.DocumentGeneration.Tests.csproj @@ -7,7 +7,7 @@ - + diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.DocumentGeneration/Dfe.PrepareConversions.DocumentGeneration.csproj b/Dfe.PrepareConversions/Dfe.PrepareConversions.DocumentGeneration/Dfe.PrepareConversions.DocumentGeneration.csproj index 92810895c..56964c851 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.DocumentGeneration/Dfe.PrepareConversions.DocumentGeneration.csproj +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.DocumentGeneration/Dfe.PrepareConversions.DocumentGeneration.csproj @@ -10,7 +10,7 @@ - + diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Redirector/Dfe.PrepareConversions.Redirector.csproj b/Dfe.PrepareConversions/Dfe.PrepareConversions.Redirector/Dfe.PrepareConversions.Redirector.csproj index 57ab39f19..09375b475 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Redirector/Dfe.PrepareConversions.Redirector.csproj +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Redirector/Dfe.PrepareConversions.Redirector.csproj @@ -9,7 +9,7 @@ - + diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Dfe.PrepareConversions.Tests.csproj b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Dfe.PrepareConversions.Tests.csproj index 20129959c..da8519812 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Dfe.PrepareConversions.Tests.csproj +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Dfe.PrepareConversions.Tests.csproj @@ -17,7 +17,7 @@ - + diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Dfe.PrepareConversions.csproj b/Dfe.PrepareConversions/Dfe.PrepareConversions/Dfe.PrepareConversions.csproj index 6b30dbff0..53326243c 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Dfe.PrepareConversions.csproj +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Dfe.PrepareConversions.csproj @@ -1,4 +1,4 @@ - + net6.0 eae6d8bd-2a58-4ed4-99e2-a82f32b0ce47 @@ -35,7 +35,7 @@ - + diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs index b86e590ae..640efc35a 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs @@ -35,6 +35,12 @@ public static class AnnexB public static readonly LinkItem Edit = AddLinkItem(page: "/AnnexB/Edit"); } + public static class ExternalApplicationForm + { + public static readonly LinkItem Index = AddLinkItem(backText: "Back", page: "/ExternalApplicationForm/Index"); + public static readonly LinkItem Edit = AddLinkItem(page: "/ExternalApplicationForm/Edit"); + } + public static class ProjectType { public static readonly LinkItem Index = AddLinkItem(backText: "Back", page: "/ProjectType/Index"); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ExternalApplicationForm/Edit.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ExternalApplicationForm/Edit.cshtml new file mode 100644 index 000000000..ec552873d --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ExternalApplicationForm/Edit.cshtml @@ -0,0 +1,53 @@ +@page "/task-list/{id:int}/ExternalApplicationForm/edit" +@using Dfe.PrepareConversions.TagHelpers +@model Dfe.PrepareConversions.Pages.ExternalApplicationForm.EditModel +@{ + ViewData["Title"] = "Have you saved the School Application form"; +} + +@section BeforeMain +{ + @Links.ExternalApplicationForm.Index.BackText + +} + +
+
+
+ @Model.Project.SchoolName +

Have you saved the school's completed Application form in SharePoint?

+
+
+
+ + +
+ +
+
+ + + + +
+
+ +
+ + +
+
+
+ + +
+
+
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ExternalApplicationForm/Edit.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ExternalApplicationForm/Edit.cshtml.cs new file mode 100644 index 000000000..837a2d96b --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ExternalApplicationForm/Edit.cshtml.cs @@ -0,0 +1,55 @@ +using Dfe.PrepareConversions.Data; +using Dfe.PrepareConversions.Data.Models; +using Dfe.PrepareConversions.Data.Services; +using Dfe.PrepareConversions.Models; +using Dfe.PrepareConversions.Services; +using Microsoft.AspNetCore.Mvc; +using System.Threading.Tasks; + +namespace Dfe.PrepareConversions.Pages.ExternalApplicationForm; + +public class EditModel : BaseAcademyConversionProjectPageModel +{ + private readonly ErrorService _errorService; + + public EditModel(IAcademyConversionProjectRepository repository, ErrorService errorService) : base(repository) + { + _errorService = errorService; + } + + [BindProperty] + public bool? YesChecked { get; set; } + + [BindProperty] + public string ExternalApplicationFormUrl { get; set; } + + public override async Task OnGetAsync(int id) + { + await base.OnGetAsync(id); + + YesChecked = Project.ExternalApplicationFormSaved; + ExternalApplicationFormUrl = Project.ExternalApplicationFormUrl; + + return Page(); + } + + public override async Task OnPostAsync(int id) + { + if (YesChecked is true && string.IsNullOrWhiteSpace(ExternalApplicationFormUrl)) + { + ModelState.AddModelError(nameof(ExternalApplicationFormUrl), "You must enter valid link for the schools application form"); + } + + if (ModelState.IsValid) + { + + await _repository.SetProjectExternalApplicationForm(id, YesChecked.Value, YesChecked is true ? ExternalApplicationFormUrl : default); + + + return RedirectToPage(Links.ExternalApplicationForm.Index.Page, new { id }); + } + + _errorService.AddErrors(ModelState.Keys, ModelState); + return await base.OnGetAsync(id); + } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ExternalApplicationForm/Index.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ExternalApplicationForm/Index.cshtml new file mode 100644 index 000000000..21a166647 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ExternalApplicationForm/Index.cshtml @@ -0,0 +1,50 @@ +@page "/task-list/{id:int}/ExternalApplicationForm" +@using Dfe.PrepareConversions.TagHelpers +@model Dfe.PrepareConversions.Pages.ExternalApplicationForm.IndexModel +@{ + ViewData["Title"] = "School application form"; +} + +@section BeforeMain +{ + @Links.ProjectList.Index.BackText +} + + + +
+
+
+ +
+
+ Have you saved the school's completed application form in SharePoint? +
+
+ Empty + Yes + No +
+
+ + ChangeExternal application form saved for the school + +
+
+ + +
+
+
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ExternalApplicationForm/Index.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ExternalApplicationForm/Index.cshtml.cs new file mode 100644 index 000000000..11eed4d9b --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ExternalApplicationForm/Index.cshtml.cs @@ -0,0 +1,15 @@ +using Dfe.PrepareConversions.Data.Services; + +namespace Dfe.PrepareConversions.Pages.ExternalApplicationForm; + +public class IndexModel : BaseAcademyConversionProjectPageModel +{ + public IndexModel(IAcademyConversionProjectRepository repository) : base(repository) + { + } + + public bool HasLink => string.IsNullOrWhiteSpace(Project.ExternalApplicationFormUrl) is false; + + public bool? AplicationFormSaved => Project.ExternalApplicationFormSaved; + public string ApplicationFormLink => Project.ExternalApplicationFormUrl; +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml index 267a34843..34bb7646a 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml @@ -14,7 +14,7 @@ -
  • +
  • @@ -22,13 +22,20 @@
  • -
  • +
  • Annex B form
  • +
  • + + School application form + +
  • > AddProjectNote(int id, AddProjectNot { return await _innerRepository.AddProjectNote(id, addProjectNote); } + + public async Task SetProjectExternalApplicationForm(int id, bool externalApplicationFormSaved, string externalApplicationFormUrl) + { + await _innerRepository.SetProjectExternalApplicationForm(id, externalApplicationFormSaved, externalApplicationFormUrl); + } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectTypeBase.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectTypeBase.cs index eb91c75b7..8475612fb 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectTypeBase.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectTypeBase.cs @@ -6,6 +6,8 @@ namespace Dfe.PrepareConversions.ViewModels; public abstract class ProjectTypeBase { protected abstract string TypeAndRouteValue { get; } + public virtual bool IsExternalSchoolApplication { get; } = false; + public bool IsSponsored => string.IsNullOrWhiteSpace(TypeAndRouteValue) is false && TypeAndRouteValue.Equals(AcademyTypeAndRoutes.Sponsored, StringComparison.InvariantCultureIgnoreCase); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs index 82df5b072..c2d699c73 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs @@ -56,6 +56,9 @@ public ProjectViewModel(AcademyConversionProject project) AnnexBFormReceived = project.AnnexBFormReceived; AnnexBFormUrl = project.AnnexBFormUrl; + ExternalApplicationFormSaved = project.ExternalApplicationFormSaved; + ExternalApplicationFormUrl = project.ExternalApplicationFormUrl; + PartOfPfiScheme = project.PartOfPfiScheme; PfiSchemeDetails = project.PfiSchemeDetails; PublishedAdmissionNumber = project.PublishedAdmissionNumber; @@ -156,6 +159,10 @@ public ProjectViewModel(AcademyConversionProject project) public bool? AnnexBFormReceived { get; set; } public string AnnexBFormUrl { get; set; } + // External Application Form + public bool? ExternalApplicationFormSaved { get; set; } + public string ExternalApplicationFormUrl { get; set; } + // School Overview public string PublishedAdmissionNumber { get; set; } public string PartOfPfiScheme { get; set; } @@ -216,4 +223,5 @@ public ProjectViewModel(AcademyConversionProject project) public ICollection Notes { get; } protected override string TypeAndRouteValue => AcademyTypeAndRoute; + public override bool IsExternalSchoolApplication => string.IsNullOrEmpty(this.ApplicationReferenceNumber); }