diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/ApiClient.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/ApiClient.cs index 9e59bdf54..9b7807ca1 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/ApiClient.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/ApiClient.cs @@ -38,7 +38,11 @@ public async Task GetProjectByIdAsync(int id) HttpResponseMessage getProjectResponse = await AcademisationClient.GetAsync(string.Format(PathFor.GetProjectById, id)); return getProjectResponse; } - + public async Task GetFormAMatProjectById(int id) + { + HttpResponseMessage getProjectResponse = await AcademisationClient.GetAsync(string.Format(PathFor.GetFormAMatProjectById, id)); + return getProjectResponse; + } public async Task UpdateProjectAsync(int id, UpdateAcademyConversionProject updateProject) { return await AcademisationClient.PatchAsync(string.Format(PathFor.UpdateProject, id), JsonContent.Create(updateProject)); @@ -93,8 +97,32 @@ public async Task SetSchoolOverview(int id, SetSchoolOvervi var formattedString = string.Format(PathFor.SetSchoolOverview, id); return await AcademisationClient.PutAsync(formattedString, JsonContent.Create(payload)); } + public async Task SetAssignedUser(int id, SetAssignedUserModel updatedAssignedUser) + { + var payload = new + { + id = updatedAssignedUser.Id, + userId = updatedAssignedUser.UserId, + fullName = updatedAssignedUser.FullName, + emailAddress = updatedAssignedUser.EmailAddress + }; + var formattedString = string.Format(PathFor.SetAssignedUser, id); + return await AcademisationClient.PutAsync(formattedString, JsonContent.Create(payload)); + } + public async Task SetFormAMatAssignedUser(int id, SetAssignedUserModel updatedAssignedUser) + { + var payload = new + { + id = updatedAssignedUser.Id, + userId = updatedAssignedUser.UserId, + fullName = updatedAssignedUser.FullName, + emailAddress = updatedAssignedUser.EmailAddress + }; + var formattedString = string.Format(PathFor.SetFormAMatAssignedUser, id); + return await AcademisationClient.PutAsync(formattedString, JsonContent.Create(payload)); + } public async Task GetAllProjectsV2Async(AcademyConversionSearchModelV2 searchModel) { return await AcademisationClient.PostAsync(PathFor.GetAllProjectsV2, JsonContent.Create(searchModel)); @@ -105,9 +133,9 @@ public async Task SetPerformanceData(int id, SetPerformance return await AcademisationClient.PutAsync(string.Format(PathFor.SetPerformanceData, id), JsonContent.Create(setPerformanceDataModel)); } - public async Task GetMATProjectsAsync(AcademyConversionSearchModelV2 searchModel) + public async Task GetFormAMatProjectsAsync(AcademyConversionSearchModelV2 searchModel) { - return await AcademisationClient.PostAsync(PathFor.GetMATProjects, JsonContent.Create(searchModel)); + return await AcademisationClient.PostAsync(PathFor.GetFormAMatProjects, JsonContent.Create(searchModel)); } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/IApiClient.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/IApiClient.cs index affaedec8..a89506096 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/IApiClient.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/IApiClient.cs @@ -10,6 +10,7 @@ public interface IApiClient Task DownloadProjectExport(AcademyConversionSearchModelV2 searchModel); Task GetAllProjectsV2Async(AcademyConversionSearchModelV2 searchModel); Task GetProjectByIdAsync(int id); + Task GetFormAMatProjectById(int id); Task UpdateProjectAsync(int id, UpdateAcademyConversionProject updateProject); Task GetFilterParametersAsync(); Task GetApplicationByReferenceAsync(string id); @@ -17,6 +18,8 @@ public interface IApiClient Task SetProjectExternalApplicationForm(int id, bool externalApplicationFormSaved, string externalApplicationFormUrl); Task SetSchoolOverview(int id, SetSchoolOverviewModel updatedSchoolOverview); + Task SetAssignedUser(int id, SetAssignedUserModel updatedAssignedUser); + Task SetFormAMatAssignedUser(int id, SetAssignedUserModel updatedAssignedUser); Task SetPerformanceData(int id, SetPerformanceDataModel setPerformanceDataModel); - Task GetMATProjectsAsync(AcademyConversionSearchModelV2 searchModel); + Task GetFormAMatProjectsAsync(AcademyConversionSearchModelV2 searchModel); } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/PathFor.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/PathFor.cs index 58ee22948..b8ae57ac0 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/PathFor.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/PathFor.cs @@ -14,13 +14,16 @@ public PathFor(IFeatureManager features) public static string GetAllProjects => "/legacy/projects"; public static string DownloadProjectExport => "/export/export-projects"; public static string GetProjectById => "/legacy/project/{0}"; + public static string GetFormAMatProjectById => "/conversion-project/formamatproject/{0}"; 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"; public static string SetPerformanceData => "/conversion-project/{0}/SetPerformanceData"; public static string SetSchoolOverview => "/conversion-project/{0}/SetSchoolOverview"; + public static string SetAssignedUser => "/conversion-project/{0}/SetAssignedUser"; + public static string SetFormAMatAssignedUser => "/conversion-project/{0}/SetFormAMatAssignedUser"; public static string GetAllProjectsV2 => "/conversion-project/projects"; - public static string GetMATProjects => "/conversion-project/MATprojects"; + public static string GetFormAMatProjects => "/conversion-project/FormAMatProjects"; } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs index c70f2a492..158e2712d 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs @@ -7,6 +7,7 @@ public class AcademyConversionProject { public int Id { get; set; } public int? Urn { get; set; } + public int? FormAMatProjectId { get; set; } public DateTime CreatedOn { get; set; } public string SchoolName { get; set; } public string SchoolPhase { get; set; } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/FormAMATProject.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/FormAMATProject.cs index d0185eb92..a25408654 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/FormAMATProject.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/FormAMATProject.cs @@ -1,137 +1,14 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; namespace Dfe.PrepareConversions.Data.Models; -public class FormAMATProject +public class FormAMatProject { public int Id { get; set; } - public int? Urn { get; set; } - public DateTime CreatedOn { get; set; } - public string SchoolName { get; set; } - public string SchoolPhase { get; set; } - public string SchoolType { get; set; } - public string LocalAuthority { get; set; } - public string ApplicationReferenceNumber { get; set; } - public string ProjectStatus { get; set; } - public DateTime? ApplicationReceivedDate { get; set; } - public DateTime? AssignedDate { get; set; } - public DateTime? HeadTeacherBoardDate { get; set; } - public DateTime? BaselineDate { get; set; } - //la summary page - public DateTime? LocalAuthorityInformationTemplateSentDate { get; set; } - public DateTime? LocalAuthorityInformationTemplateReturnedDate { get; set; } - public string LocalAuthorityInformationTemplateComments { get; set; } - public string LocalAuthorityInformationTemplateLink { get; set; } - public bool? LocalAuthorityInformationTemplateSectionComplete { get; set; } - - //school/trust info - public string RecommendationForProject { get; set; } - public string Author { get; set; } - public string Version { get; set; } - public string ClearedBy { get; set; } - public string AcademyOrderRequired { get; set; } - public string PreviousHeadTeacherBoardDateQuestion { get; set; } - public DateTime? PreviousHeadTeacherBoardDate { get; set; } - public string PreviousHeadTeacherBoardLink { get; set; } - public string TrustReferenceNumber { get; set; } - public string NameOfTrust { get; set; } - public string SponsorReferenceNumber { get; set; } - public string SponsorName { get; set; } - public string AcademyTypeAndRoute { get; set; } - public string Form7Received { get; set; } - public DateTime? Form7ReceivedDate { get; set; } - public DateTime? ProposedAcademyOpeningDate { get; set; } - public bool? SchoolAndTrustInformationSectionComplete { get; set; } - public decimal? ConversionSupportGrantAmount { get; set; } - public string ConversionSupportGrantChangeReason { get; set; } - public string ConversionSupportGrantType { get; set; } - public string ConversionSupportGrantEnvironmentalImprovementGrant { get; set; } - public bool? ConversionSupportGrantAmountChanged { get; set; } - public string ConversionSupportGrantNumberOfSites { get; set; } - public DateTime? DaoPackSentDate { get; set; } - public string Region { get; set; } - - // Annex B - 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; } - public string PfiSchemeDetails { get; set; } - public string ViabilityIssues { get; set; } - public decimal? NumberOfPlacesFundedFor { get; set; } - public decimal? NumberOfResidentialPlaces { get; set; } - public decimal? NumberOfFundedResidentialPlaces { get; set; } - public string FinancialDeficit { get; set; } - public decimal? DistanceFromSchoolToTrustHeadquarters { get; set; } - public string DistanceFromSchoolToTrustHeadquartersAdditionalInformation { get; set; } - public string MemberOfParliamentNameAndParty { get; set; } - public bool? SchoolOverviewSectionComplete { get; set; } - public bool? PupilsAttendingGroupPermanentlyExcluded { get; set; } - public bool? PupilsAttendingGroupMedicalAndHealthNeeds { get; set; } - public bool? PupilsAttendingGroupTeenageMums { get; set; } - public int? NumberOfAlternativeProvisionPlaces { get; set; } - public int? NumberOfMedicalPlaces { get; set; } - public int? NumberOfPost16Places { get; set; } - public int? NumberOfSENUnitPlaces { get; set; } - - //school performance ofsted information - public string SchoolPerformanceAdditionalInformation { get; set; } - - // rationale - public string RationaleForProject { get; set; } - public string RationaleForTrust { get; set; } - public bool? RationaleSectionComplete { get; set; } - - // risk and issues - public string RisksAndIssues { get; set; } - public bool? RisksAndIssuesSectionComplete { get; set; } - - // legal requirements - public string GoverningBodyResolution { get; set; } - public string Consultation { get; set; } - public string DiocesanConsent { get; set; } - public string FoundationConsent { get; set; } - public bool? LegalRequirementsSectionComplete { get; set; } - - // school budget info - public DateTime? EndOfCurrentFinancialYear { get; set; } - public decimal? RevenueCarryForwardAtEndMarchCurrentYear { get; set; } - public decimal? CapitalCarryForwardAtEndMarchCurrentYear { get; set; } - public DateTime? EndOfNextFinancialYear { get; set; } - public decimal? ProjectedRevenueBalanceAtEndMarchNextYear { get; set; } - public decimal? CapitalCarryForwardAtEndMarchNextYear { get; set; } - public string SchoolBudgetInformationAdditionalInformation { get; set; } - public bool? SchoolBudgetInformationSectionComplete { get; set; } - - // pupil schools forecast - public int? YearOneProjectedCapacity { get; set; } - public int? YearOneProjectedPupilNumbers { get; set; } - public int? YearTwoProjectedCapacity { get; set; } - public int? YearTwoProjectedPupilNumbers { get; set; } - public int? YearThreeProjectedCapacity { get; set; } - public int? YearThreeProjectedPupilNumbers { get; set; } - public int? YearFourProjectedCapacity { get; set; } - public int? YearFourProjectedPupilNumbers { get; set; } - public string SchoolPupilForecastsAdditionalInformation { get; set; } - - // key stage performance tables - public string KeyStage2PerformanceAdditionalInformation { get; set; } - public string KeyStage4PerformanceAdditionalInformation { get; set; } - public string KeyStage5PerformanceAdditionalInformation { get; set; } - public string EducationalAttendanceAdditionalInformation { get; set; } - - // assigned user + public string ProposedTrustName { get; set; } + public string ApplicationReference { get; set; } public User AssignedUser { get; set; } - - // notes - public ICollection Notes { get; set; } = new List(); + public ICollection Projects { get; set; } = new List(); } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/SetAssignedUserModel.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/SetAssignedUserModel.cs new file mode 100644 index 000000000..80599ec0f --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/SetAssignedUserModel.cs @@ -0,0 +1,26 @@ +using System; + +namespace Dfe.PrepareConversions.Data.Models +{ + public class SetAssignedUserModel + { + public SetAssignedUserModel() { } + public SetAssignedUserModel( + int id, + Guid userId, + string fullName, + string emailAddress) + { + Id = id; + UserId = userId; + FullName = fullName; + EmailAddress = emailAddress; + } + + public int Id { get; set; } + public Guid UserId { get; set; } + public string FullName { get; set; } + + public string EmailAddress { get; set; } + } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/AcademyConversionProjectRepository.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/AcademyConversionProjectRepository.cs index 964972fc7..44bce5331 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/AcademyConversionProjectRepository.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/AcademyConversionProjectRepository.cs @@ -66,7 +66,17 @@ public async Task> GetProjectById(int id) AcademyConversionProject project = await ReadFromJsonAndThrowIfNull(response.Content); return new ApiResponse(response.StatusCode, project); } + public async Task> GetFormAMatProjectById(int id) + { + HttpResponseMessage response = await _apiClient.GetFormAMatProjectById(id); + if (!response.IsSuccessStatusCode) + { + return new ApiResponse(response.StatusCode, null); + } + FormAMatProject project = await ReadFromJsonAndThrowIfNull(response.Content); + return new ApiResponse(response.StatusCode, project); + } public async Task> UpdateProject(int id, UpdateAcademyConversionProject updateProject) { ApiResponse projectResponse = await GetProjectById(id); @@ -250,6 +260,16 @@ public async Task SetSchoolOverview(int id, SetSchoolOverviewModel updatedSchool HttpResponseMessage result = await _apiClient.SetSchoolOverview(id, updatedSchoolOverview); if (result.IsSuccessStatusCode is false) throw new ApiResponseException($"Request to Api failed | StatusCode - {result.StatusCode}"); } + public async Task SetAssignedUser(int id, SetAssignedUserModel updatedAssignedUser) + { + HttpResponseMessage result = await _apiClient.SetAssignedUser(id, updatedAssignedUser); + if (result.IsSuccessStatusCode is false) throw new ApiResponseException($"Request to Api failed | StatusCode - {result.StatusCode}"); + } + public async Task SetFormAMatAssignedUser(int id, SetAssignedUserModel updatedAssignedUser) + { + HttpResponseMessage result = await _apiClient.SetFormAMatAssignedUser(id, updatedAssignedUser); + if (result.IsSuccessStatusCode is false) throw new ApiResponseException($"Request to Api failed | StatusCode - {result.StatusCode}"); + } public async Task>>> GetAllProjectsV2(int page, int count, string titleFilter = "", IEnumerable statusFilters = null, IEnumerable deliveryOfficerFilter = null, IEnumerable regionsFilter = null, IEnumerable localAuthoritiesFilter = null, IEnumerable advisoryBoardDatesFilter = null) { @@ -269,22 +289,22 @@ public async Task return new ApiResponse>>(response.StatusCode, outerResponse); } - public async Task>>> GetMATProjects(int page, int count, string titleFilter = "", IEnumerable statusFilters = null, IEnumerable deliveryOfficerFilter = null, IEnumerable regionsFilter = null, IEnumerable localAuthoritiesFilter = null, IEnumerable advisoryBoardDatesFilter = null) + public async Task>>> GetFormAMatProjects(int page, int count, string titleFilter = "", IEnumerable statusFilters = null, IEnumerable deliveryOfficerFilter = null, IEnumerable regionsFilter = null, IEnumerable localAuthoritiesFilter = null, IEnumerable advisoryBoardDatesFilter = null) { AcademyConversionSearchModelV2 searchModel = new() { TitleFilter = titleFilter, Page = page, Count = count }; ProcessFiltersV2(statusFilters, deliveryOfficerFilter, searchModel, regionsFilter, localAuthoritiesFilter, advisoryBoardDatesFilter); - HttpResponseMessage response = await _apiClient.GetMATProjectsAsync(searchModel); + HttpResponseMessage response = await _apiClient.GetFormAMatProjectsAsync(searchModel); if (!response.IsSuccessStatusCode) { - return new ApiResponse>>(response.StatusCode, - new ApiV2Wrapper> { Data = Enumerable.Empty() }); + return new ApiResponse>>(response.StatusCode, + new ApiV2Wrapper> { Data = Enumerable.Empty() }); } - ApiV2Wrapper> outerResponse = await response.Content.ReadFromJsonAsync>>(); + ApiV2Wrapper> outerResponse = await response.Content.ReadFromJsonAsync>>(); - return new ApiResponse>>(response.StatusCode, outerResponse); + return new ApiResponse>>(response.StatusCode, outerResponse); } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/ApiV2PagingInfo.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/ApiV2PagingInfo.cs index 70b92d9fc..fc9ff31d9 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/ApiV2PagingInfo.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/ApiV2PagingInfo.cs @@ -4,5 +4,5 @@ public class ApiV2PagingInfo { public int Page { get; set; } public int RecordCount { get; set; } - public string NextPageUrl { get; set; } + public string? NextPageUrl { get; set; } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IAcademyConversionProjectRepository.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IAcademyConversionProjectRepository.cs index 1fbbba194..9a89dac10 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IAcademyConversionProjectRepository.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IAcademyConversionProjectRepository.cs @@ -39,7 +39,7 @@ Task>>> GetAllPro IEnumerable advisoryBoardDatesFilter = default ); - Task>>> GetMATProjects( + Task>>> GetFormAMatProjects( int page, int count, string titleFilter = "", @@ -51,9 +51,12 @@ Task>>> GetMATProjects( ); Task> GetProjectById(int id); + Task> GetFormAMatProjectById(int id); Task> UpdateProject(int id, UpdateAcademyConversionProject updateProject); Task CreateProject(CreateNewProject newProject); Task SetProjectExternalApplicationForm(int id, bool externalApplicationFormSaved, string externalApplicationFormUrl); + Task SetAssignedUser(int id, SetAssignedUserModel updatedAssignedUser); + Task SetFormAMatAssignedUser(int id, SetAssignedUserModel updatedAssignedUser); Task SetSchoolOverview(int id, SetSchoolOverviewModel updatedSchoolOverview); Task SetPerformanceData(int id, SetPerformanceDataModel setPerformanceDataModel); Task> GetFilterParameters(); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/IntegrationTestingWebApplicationFactory.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/IntegrationTestingWebApplicationFactory.cs index 470e4f96e..421bf8fc3 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/IntegrationTestingWebApplicationFactory.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/IntegrationTestingWebApplicationFactory.cs @@ -47,6 +47,8 @@ public IntegrationTestingWebApplicationFactory() public ITestOutputHelper DebugOutput { get; set; } + public IUserRepository UserRepository { get; private set; } + public IEnumerable GetMockServerLogs(string path, HttpMethod verb = null) { IRequestBuilder requestBuilder = Request.Create().WithPath(path); @@ -83,11 +85,13 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) featureManager.Setup(m => m.IsEnabledAsync("UseAcademisationApplication")).ReturnsAsync(true); featureManager.Setup(m => m.IsEnabledAsync("ShowDirectedAcademyOrders")).ReturnsAsync(true); + UserRepository = new TestUserRepository(); + builder.ConfigureServices(services => { services.AddAuthentication("Test"); services.AddTransient(); - services.AddTransient(); + services.AddScoped(x => UserRepository); services.AddTransient(_ => featureManager.Object); }); } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/BaseIntegrationTests.MockData.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/BaseIntegrationTests.MockData.cs index bd434f0bd..6f515bd7c 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/BaseIntegrationTests.MockData.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/BaseIntegrationTests.MockData.cs @@ -163,6 +163,39 @@ public SetPerformanceDataModel AddPutPerformanceData(AcademyConversionProject pr _factory.AddPutWithJsonRequest(string.Format(PathFor.SetPerformanceData, project.Id), request, project); return request; } + public SetAssignedUserModel AddSetAssignUser(AcademyConversionProject project, string fullName) + { + var deliveryOfficers = _factory.UserRepository.GetAllUsers().Result; + var assignedUser = deliveryOfficers.SingleOrDefault(u => u.FullName == fullName); + SetAssignedUserModel request; + + if (assignedUser == null) + { + request = _fixture + .Build() + .OmitAutoProperties() + .With(x => x.Id, project.Id) + .With(x => x.UserId, Guid.Empty) + .With(x => x.FullName, string.Empty) + .With(x => x.EmailAddress, string.Empty) + .Create(); + } + else + { + request = _fixture + .Build() + .OmitAutoProperties() + .With(x => x.Id, project.Id) + .With(x => x.UserId, Guid.Parse(assignedUser.Id)) + .With(x => x.FullName, fullName) + .With(x => x.EmailAddress, assignedUser.EmailAddress) + .Create(); + } + + _factory.AddPutWithJsonRequest(string.Format(PathFor.SetAssignedUser, project.Id), request, project); + return request; + } + public UpdateAcademyConversionProject AddPatchProjectMany(AcademyConversionProject project, Func, IPostprocessComposer> diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/ProjectAssignment/ProjectAssignmentIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/ProjectAssignment/ProjectAssignmentIntegrationTests.cs index 1330deec8..c27f393c8 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/ProjectAssignment/ProjectAssignmentIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/ProjectAssignment/ProjectAssignmentIntegrationTests.cs @@ -31,12 +31,14 @@ public async Task Should_redirect_to_assign_project_page() [Fact] public async Task Should_assign_a_project() { - AcademyConversionProject project = AddGetProject(); + AcademyConversionProject project = AddGetProject(); await OpenAndConfirmPathAsync($"/project-assignment/{project.Id}"); string fullName = "Bob 1"; + AddSetAssignUser(project, fullName); + Document.QuerySelector("[id='delivery-officer-input']")!.Value = fullName; Document.QuerySelector($"[value='{fullName}']")!.IsSelected = true; - await Document.QuerySelector("form")!.SubmitAsync(); + await Document.QuerySelector("form")!.SubmitAsync(); Document.QuerySelector("#notification-message")!.TextContent.Trim().Should() .Be("Project is assigned"); @@ -69,7 +71,7 @@ public async Task Should_unassign_a_project() { AcademyConversionProject project = AddGetProject(); await OpenAndConfirmPathAsync($"/project-assignment/{project.Id}"); - + AddSetAssignUser(project, string.Empty); Document.QuerySelector("#UnassignDeliveryOfficer")!.Value = "true"; await Document.QuerySelector("form")!.SubmitAsync(); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/ProjectAssignment/TestUserRepository.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/ProjectAssignment/TestUserRepository.cs index 47369c784..ff0f8d193 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/ProjectAssignment/TestUserRepository.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/ProjectAssignment/TestUserRepository.cs @@ -1,5 +1,6 @@ using Dfe.PrepareConversions.Data.Models; using Dfe.PrepareConversions.Data.Services.Interfaces; +using DocumentFormat.OpenXml.Spreadsheet; using System; using System.Collections.Generic; using System.Linq; @@ -9,12 +10,15 @@ namespace Dfe.PrepareConversions.Tests.Pages.ProjectAssignment; public class TestUserRepository : IUserRepository { + private List users = new(); + public Task> GetAllUsers() { - List toReturn = new(); - for (int i = 0; i < 30; i++) - toReturn.Add(new User(Guid.NewGuid().ToString(), $"bob.{i}@education.gov.uk", $"Bob {i}")); - - return Task.FromResult(toReturn.AsEnumerable()); + if (users.Count == 0) + { + for (int i = 0; i < 30; i++) + users.Add(new User(Guid.NewGuid().ToString(), $"bob.{i}@education.gov.uk", $"Bob {i}")); + } + return Task.FromResult(users.AsEnumerable()); } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/ProjectList/ProjectListIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/ProjectList/ProjectListIntegrationTests.cs index e68fec4b4..351952bbe 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/ProjectList/ProjectListIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/ProjectList/ProjectListIntegrationTests.cs @@ -28,7 +28,7 @@ public async Task Should_display_list_of_projects_and_navigate_to_and_from_task_ AcademyConversionProject firstProject = AddGetProject(p => p.Id = projects.First().Id); await NavigateAsync(projects.First().SchoolName); - Document.Url.Should().BeUrl($"/task-list/{firstProject.Id}"); + Document.Url.Should().BeUrl($"/task-list/{firstProject.Id}?returnToFormAMatMenu=False"); await NavigateAsync("Back"); Document.Url.Should().BeUrl("/project-list"); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Extensions/ProjectListRowViewModelHelpers.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Extensions/ProjectListRowViewModelHelpers.cs index 47fd47967..acb65aad6 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Extensions/ProjectListRowViewModelHelpers.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Extensions/ProjectListRowViewModelHelpers.cs @@ -8,4 +8,9 @@ public static ProjectListRowViewModel Row(this ProjectListViewModel project, int { return new ProjectListRowViewModel { Item = project, Index = index }; } + + public static FormAMatProjectListRowViewModel Row(this FormAMatProjectListViewModel project, int index) + { + return new FormAMatProjectListRowViewModel { Item = project, Index = index }; + } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs index 9270d80e1..831ecdb6a 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs @@ -49,6 +49,7 @@ public static class ProjectType public static class ProjectAssignment { public static readonly LinkItem Index = AddLinkItem(backText: "Back", page: "/ProjectAssignment/Index"); + public static readonly LinkItem FormAMatProjectAssignment = AddLinkItem(backText: "Back", page: "/ProjectAssignment/FormAMatProjectAssignment"); } public static class ProjectList @@ -73,7 +74,9 @@ public static class TaskList public static class FormAMat { public static readonly LinkItem Index = AddLinkItem(backText: "Back", page: "/FormAMat/Index"); - public static readonly LinkItem OtherSchoolsInMat = AddLinkItem(backText: "Back to project listing", page: "/FormAMat/OtherSchoolsInMat"); + // not sure these are right probably need to look at this, they look the wrong way round + public static readonly LinkItem OtherSchoolsInMat = AddLinkItem(backText: "Back to project listing", page: "/FormAMat/FormAMatParentIndex"); + public static readonly LinkItem FormAMatProjectPage = AddLinkItem(backText: "Back to project listing", page: "/schools-in-this-mat"); } public static class SchoolPerformance diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/FormAMatParentIndex.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/FormAMatParentIndex.cshtml new file mode 100644 index 000000000..e70af2f6d --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/FormAMatParentIndex.cshtml @@ -0,0 +1,140 @@ +@page "/schools-in-this-mat/{id:int}" +@using Dfe.Academisation.ExtensionMethods +@model Dfe.PrepareConversions.Pages.FormAMat.FormAMatParentIndex +@{ + ViewData["Title"] = "Schools in this MAT"; +} + +@section BeforeMain +{ + @Links.ProjectList.FormAMat.BackText +} + +
+
+ Application ref: @Model.Project.ApplciationReference +

+ @Model.Project.TrustName +

+

+ Assigned to: + + @if (Model.Project.AssignedUserFullName == null || string.IsNullOrWhiteSpace(Model?.Project?.AssignedUserFullName)) + { + Empty + } + else + { + @Model.Project.AssignedUserFullName + } + + Change +

+

+ @{ + var statusSummary = Model.Statuses + .GroupBy(status => new { status.Value, status.Colour }) + .Select(group => new { Status = group.Key.Value, Colour = group.Key.Colour, Count = group.Count() }) + .ToList(); + + foreach (var status in statusSummary) + { + @status.Count @status.Status + } + } + +

+
+
+ +
+
+ +
+
+ + + + + + + + @{ + var index = 0; + + foreach (var project in Model.Projects) + { + var projectRow = project.Row(index); + + var isFormAMat = project.IsFormAMat; + var matTypeClass = isFormAMat ? "form-a-mat" : "join-a-mat"; + var link = @Links.TaskList.Index.Page; + + + + + + index++; + } + } + +
Application information
+ +
+ URN: @projectRow.Item.SchoolURN +
+ @if (!@projectRow.Item.LocalAuthority.IsEmpty()) + { +
+ Local authority: + @projectRow.Item.LocalAuthority +
+ } +
+ Region: + Empty + @projectRow.Item.Region +
+
+ Incoming trust: + Empty + @projectRow.Item.NameOfTrust?.ToTitleCase() +
+
+ Advisory board date: + Unconfirmed + @projectRow.Item.HeadTeacherBoardDate +
+
+ Route: + Unconfirmed + @projectRow.Item.TypeAndRoute.RouteDescription() +
+ @if (!isFormAMat) + { +
+ Assigned to: + Unassigned + @projectRow.Item.AssignedUserFullName +
+ } +
+ @projectRow.Item.Status.Value +
+
+
+
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/FormAMatParentIndex.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/FormAMatParentIndex.cshtml.cs new file mode 100644 index 000000000..74386495c --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/FormAMatParentIndex.cshtml.cs @@ -0,0 +1,62 @@ +using Dfe.PrepareConversions.Data.Services; +using Dfe.PrepareConversions.Models.ProjectList; +using Dfe.PrepareConversions.Utils; +using Dfe.PrepareConversions.ViewModels; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Threading.Tasks; + +namespace Dfe.PrepareConversions.Pages.FormAMat; + +public class FormAMatParentIndex : PageModel +{ + private readonly IAcademyConversionProjectRepository _repository; + public FormAMatProjectViewModel Project { get; set; } + + public FormAMatParentIndex(IAcademyConversionProjectRepository repository) + { + _repository = repository; + } + + public List Projects { get; set; } + public List Statuses { get; set; } + + [BindProperty] + public ProjectListFilters Filters { get; set; } = new(); + + public async Task OnGetAsync(int id) + { + IActionResult result = await SetFormAMatProject(id); + Projects = Project.Projects.Select(AcademyConversionProject => ProjectListHelper.Build(AcademyConversionProject)).ToList(); + Statuses = GetProjectStatuses(); + if ((result as StatusCodeResult)?.StatusCode == (int)HttpStatusCode.NotFound) + { + return NotFound(); + } + + TempData["returnToFormAMatMenu"] = true; + + return Page(); + } + protected async Task SetFormAMatProject(int id) + { + var FamProject = await _repository.GetFormAMatProjectById(id); + + if (!FamProject.Success) + { + // 404 logic + return NotFound(); + } + + Project = new FormAMatProjectViewModel(FamProject.Body); + return Page(); + } + + public List GetProjectStatuses() + { + return Projects.Select(x => x.Status).ToList(); + } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/Index.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/Index.cshtml index 66ca0e540..c8f3707c4 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/Index.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/Index.cshtml @@ -9,10 +9,10 @@ @section BeforeMain { - @Links.ProjectList.Index.BackText + @Links.ProjectList.Index.BackText } - +
diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/Index.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/Index.cshtml.cs index 68a71fa2c..92b1ae630 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/Index.cshtml.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/Index.cshtml.cs @@ -12,6 +12,7 @@ using System.Net; using System.Threading.Tasks; using System.Collections.Generic; +using Dfe.PrepareConversions.Models; namespace Dfe.PrepareConversions.Pages.FormAMat; @@ -19,6 +20,9 @@ public class FormAMatIndexModel : BaseAcademyConversionProjectPageModel { protected readonly ApplicationRepository _applicationRepository; public IEnumerable Sections { get; set; } + + public string ReturnPage { get; set; } + public string ReturnId { get; set; } public FormAMatIndexModel(IAcademyConversionProjectRepository repository, ApplicationRepository applicationRepository) : base(repository) { _applicationRepository = applicationRepository; @@ -69,6 +73,16 @@ public override async Task OnGetAsync(int id) new DeclarationSection(currentSchool) }; + ReturnPage = @Links.ProjectList.Index.Page; + var returnToFormAMatMenu = TempData["returnToFormAMatMenu"] as bool?; + + if (Project.IsFormAMat && returnToFormAMatMenu.HasValue && returnToFormAMatMenu.Value) + { + ReturnId = Project.FormAMatProjectId.ToString(); + ReturnPage = @Links.FormAMat.OtherSchoolsInMat.Page; + TempData["returnToFormAMatMenu"] = true; + } + return result; } public string GenerateId(string heading) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/OtherSchoolsInMat.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/OtherSchoolsInMat.cshtml deleted file mode 100644 index 0129feb68..000000000 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/OtherSchoolsInMat.cshtml +++ /dev/null @@ -1,36 +0,0 @@ -@page "/schools-in-this-mat/{id:int}" -@model Dfe.PrepareConversions.Pages.FormAMat.OtherSchoolsInMatModel -@{ - ViewData["Title"] = "Schools in this MAT"; -} - -@section BeforeMain -{ - @Links.ProjectList.Index.BackText -} - - - -
-
-

Other schools in this MAT

- - - - - - - - - @{ - var index = 0; - foreach (ProjectListViewModel project in Model.Projects) - { - - index++; - } - } - -
Application informationProject status and dates
-
-
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/OtherSchoolsInMat.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/OtherSchoolsInMat.cshtml.cs deleted file mode 100644 index 1ac84bce1..000000000 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/OtherSchoolsInMat.cshtml.cs +++ /dev/null @@ -1,69 +0,0 @@ -using Dfe.PrepareConversions.Data.Services; -using Dfe.PrepareConversions.Models.ProjectList; -using Dfe.PrepareConversions.Data.Models; -using Dfe.PrepareConversions.Data; -using Dfe.PrepareConversions.Utils; -using Dfe.PrepareConversions.ViewModels; -using Microsoft.AspNetCore.Mvc; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Threading.Tasks; - -namespace Dfe.PrepareConversions.Pages.FormAMat; - -public class OtherSchoolsInMatModel : PaginatedPageModel -{ - private readonly IAcademyConversionProjectRepository _repository; - public ProjectViewModel Project { get; set; } - - public OtherSchoolsInMatModel(IAcademyConversionProjectRepository repository) - { - _repository = repository; - } - - protected override ApiV2PagingInfo Paging { get; set; } - - public IEnumerable Projects { get; set; } - - public int TotalProjects { get; set; } - - [BindProperty] - public ProjectListFilters Filters { get; set; } = new(); - - public async Task OnGetAsync(int id) - { - ProjectListFilters.ClearFiltersFrom(TempData); - - IActionResult result = await SetProject(id); - - if ((result as StatusCodeResult)?.StatusCode == (int)HttpStatusCode.NotFound) - { - return NotFound(); - } - - ApiResponse>> response = - await _repository.GetAllProjects(CurrentPage, 50, Filters.Title, Filters.SelectedStatuses, Filters.SelectedOfficers, Filters.SelectedRegions, - new List { Project.ApplicationReferenceNumber }); - - Paging = response.Body?.Paging; - Projects = response.Body?.Data.Select(ProjectListHelper.Build).ToList(); - var currentSchool = Project.SchoolURN; - Projects = Projects!.Where(x => x.SchoolURN != currentSchool); - TotalProjects = response.Body?.Paging?.RecordCount ?? 0; - - return Page(); - } - protected async Task SetProject(int id) - { - var project = await _repository.GetProjectById(id); - if (!project.Success) - { - // 404 logic - return NotFound(); - } - - Project = new ProjectViewModel(project.Body); - return Page(); - } -} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/ProjectList.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/ProjectList.cshtml index 4d351d13b..b2c2c4968 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/ProjectList.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/ProjectList.cshtml @@ -30,6 +30,17 @@
+

@(Model.TotalProjects) projects found

+ +
+
There are no matching results.
+

Improve your results by:

+
    +
  • double-checking your spelling
  • +
  • searching again with another school
  • +
  • removing some filters
  • +
+
@@ -42,7 +53,7 @@ @{ - + } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/ProjectList.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/ProjectList.cshtml.cs index e14f25459..a5fef82f0 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/ProjectList.cshtml.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/FormAMat/ProjectList.cshtml.cs @@ -8,7 +8,6 @@ using Dfe.PrepareConversions.ViewModels; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Threading.Tasks; @@ -24,7 +23,7 @@ public ProjectListModel(IAcademyConversionProjectRepository repository) } public IEnumerable Sections { get; set; } protected override ApiV2PagingInfo Paging { get; set; } - public IEnumerable Projects { get; set; } + public IEnumerable Projects { get; set; } public int ProjectCount => Projects.Count(); public int TotalProjects { get; set; } @@ -35,9 +34,9 @@ public ProjectListModel(IAcademyConversionProjectRepository repository) public async Task OnGetAsync() { Filters.PersistUsing(TempData).PopulateFrom(Request.Query); - - ApiResponse>> response = - await _repository.GetMATProjects(CurrentPage, PageSize, Filters.Title, Filters.SelectedStatuses, Filters.SelectedOfficers, Filters.SelectedRegions, Filters.SelectedLocalAuthorities, Filters.SelectedAdvisoryBoardDates); + this.PagePath = "/FormAMat/ProjectList"; + ApiResponse>> response = + await _repository.GetFormAMatProjects(CurrentPage, PageSize, Filters.Title, Filters.SelectedStatuses, Filters.SelectedOfficers, Filters.SelectedRegions, Filters.SelectedLocalAuthorities, Filters.SelectedAdvisoryBoardDates); Paging = response.Body?.Paging; Projects = response.Body?.Data.Select(ProjectListHelper.Build).ToList(); @@ -54,29 +53,5 @@ public async Task OnGetAsync() Filters.AvailableAdvisoryBoardDates = filterParametersResponse.Body.AdvisoryBoardDates; } } - public async Task OnGetDownload() - { - Filters.PersistUsing(TempData).PopulateFrom(Request.Query); - ApiResponse response = await _repository.DownloadProjectExport(CurrentPage, PageSize, Filters.Title, Filters.SelectedStatuses, Filters.SelectedOfficers, Filters.SelectedRegions, Filters.SelectedLocalAuthorities, Filters.SelectedAdvisoryBoardDates); - - if (response.Success) - { - return response.Body; - } - else - { - var stream = new MemoryStream(); - var writer = new StreamWriter(stream); - writer.Write(""); - writer.Flush(); - stream.Position = 0; - - var fileStreamResult = new FileStreamResult(stream, "text/csv") - { - FileDownloadName = "empty.csv" - }; - return fileStreamResult; - } - } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/NewProject/SearchSchool.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/NewProject/SearchSchool.cshtml.cs index 06a60b4b3..e1968cdab 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/NewProject/SearchSchool.cshtml.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/NewProject/SearchSchool.cshtml.cs @@ -75,9 +75,9 @@ public async Task OnPost(string ukprn, string redirect) return Page(); } - string expectedUkprn = splitSearch[1]; + string expectedUrn = splitSearch[splitSearch.Length - 1]; ; - var expectedEstablishment = await _getEstablishment.GetEstablishmentByUrn(expectedUkprn); + var expectedEstablishment = await _getEstablishment.GetEstablishmentByUrn(expectedUrn); if (expectedEstablishment.Name == null) { @@ -88,7 +88,7 @@ public async Task OnPost(string ukprn, string redirect) redirect = string.IsNullOrEmpty(redirect) ? Links.NewProject.SchoolApply.Page : redirect; - return RedirectToPage(redirect, new { urn = splitSearch[1], ukprn }); + return RedirectToPage(redirect, new { urn = expectedUrn, ukprn }); } private static string HighlightSearchMatch(string input, string toReplace, EstablishmentSearchResponse school) @@ -103,6 +103,9 @@ private static string HighlightSearchMatch(string input, string toReplace, Estab private static string[] SplitOnBrackets(string input) { - return input.Split(new[] { '(', ')' }, 3, StringSplitOptions.None); + // return array containing one empty string if input string is null or empty + if (string.IsNullOrWhiteSpace(input)) return new string[1] { string.Empty }; + + return input.Split(new[] { '(', ')' }, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries); } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectAssignment/FormAMatProjectAssignment.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectAssignment/FormAMatProjectAssignment.cshtml new file mode 100644 index 000000000..709d22988 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectAssignment/FormAMatProjectAssignment.cshtml @@ -0,0 +1,77 @@ +@page "/fam-project-assignment/{id:int}" +@using Dfe.PrepareConversions.Data.Models +@using NetEscapades.AspNetCore.SecurityHeaders.TagHelpers +@model Dfe.PrepareConversions.Pages.ProjectAssignment.FormAMatProjectAssignmentModel +@{ + ViewData["Title"] = "Who will be on this project?"; +} + +@section BeforeMain +{ + Back +} + +
+
+ + @Model.TrustName +

Who will be on this project?

+ +
+ + +
+ The delivery officer responsible for this project +
+ +
+ + + + +
+ + + or Unassign the delivery officer +
+
+
+ +
+
+ + \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectAssignment/FormAMatProjectAssignment.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectAssignment/FormAMatProjectAssignment.cshtml.cs new file mode 100644 index 000000000..810a3700e --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectAssignment/FormAMatProjectAssignment.cshtml.cs @@ -0,0 +1,66 @@ +using Dfe.PrepareConversions.Data; +using Dfe.PrepareConversions.Data.Models; +using Dfe.PrepareConversions.Data.Services; +using Dfe.PrepareConversions.Data.Services.Interfaces; +using Dfe.PrepareConversions.Extensions; +using Dfe.PrepareConversions.Models; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Dfe.PrepareConversions.Pages.ProjectAssignment; + +public class FormAMatProjectAssignmentModel : PageModel +{ + private readonly IAcademyConversionProjectRepository _academyConversionProjectRepository; + private readonly IUserRepository _userRepository; + + public FormAMatProjectAssignmentModel(IUserRepository userRepository, IAcademyConversionProjectRepository academyConversionProjectRepository) + { + _academyConversionProjectRepository = academyConversionProjectRepository; + _userRepository = userRepository; + } + + public string TrustName { get; private set; } + public int Id { get; set; } + public IEnumerable DeliveryOfficers { get; set; } + public string SelectedDeliveryOfficer { get; set; } + + public async Task OnGet(int id) + { + ApiResponse projectResponse = await _academyConversionProjectRepository.GetFormAMatProjectById(id); + Id = id; + TrustName = projectResponse.Body.ProposedTrustName; + SelectedDeliveryOfficer = projectResponse.Body?.AssignedUser?.FullName; + + DeliveryOfficers = await _userRepository.GetAllUsers(); + + return Page(); + } + + public async Task OnPost(int id, string selectedName, bool unassignDeliveryOfficer, string deliveryOfficerInput) + { + ApiResponse projectResponse = await _academyConversionProjectRepository.GetFormAMatProjectById(id); + + if (unassignDeliveryOfficer) + { + await _academyConversionProjectRepository.SetFormAMatAssignedUser(id, new SetAssignedUserModel(id, Guid.Empty, string.Empty, string.Empty)); + TempData.SetNotification(NotificationType.Success, "Done", "Project is unassigned"); + } + else if (!string.IsNullOrEmpty(selectedName)) + { + IEnumerable deliveryOfficers = await _userRepository.GetAllUsers(); + + var assignedUser = deliveryOfficers.SingleOrDefault(u => u.FullName == selectedName); + + await _academyConversionProjectRepository.SetFormAMatAssignedUser(id, new SetAssignedUserModel(id, new Guid(assignedUser.Id), assignedUser.FullName, assignedUser.EmailAddress)); + TempData.SetNotification(NotificationType.Success, "Done", "Project is assigned"); + } + + + return RedirectToPage(Links.FormAMat.OtherSchoolsInMat.Page, new { id }); + } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectAssignment/Index.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectAssignment/Index.cshtml.cs index b11f076e6..36f07d25f 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectAssignment/Index.cshtml.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectAssignment/Index.cshtml.cs @@ -43,6 +43,7 @@ public async Task OnGet(int id) public async Task OnPost(int id, string selectedName, bool unassignDeliveryOfficer, string deliveryOfficerInput) { + ApiResponse projectResponse = await _academyConversionProjectRepository.GetProjectById(id); if (string.IsNullOrWhiteSpace(deliveryOfficerInput)) { selectedName = string.Empty; @@ -50,17 +51,16 @@ public async Task OnPost(int id, string selectedName, bool unassi if (unassignDeliveryOfficer) { - UpdateAcademyConversionProject updatedProject = new() { AssignedUser = new User(Guid.Empty.ToString(), string.Empty, string.Empty) }; - - await _academyConversionProjectRepository.UpdateProject(id, updatedProject); + await _academyConversionProjectRepository.SetAssignedUser(id, new SetAssignedUserModel(id, Guid.Empty, string.Empty, string.Empty)); TempData.SetNotification(NotificationType.Success, "Done", "Project is unassigned"); } else if (!string.IsNullOrEmpty(selectedName)) { IEnumerable deliveryOfficers = await _userRepository.GetAllUsers(); - UpdateAcademyConversionProject updatedProject = new() { AssignedUser = deliveryOfficers.SingleOrDefault(u => u.FullName == selectedName) }; - await _academyConversionProjectRepository.UpdateProject(id, updatedProject); + var assignedUser = deliveryOfficers.SingleOrDefault(u => u.FullName == selectedName); + + await _academyConversionProjectRepository.SetAssignedUser(id, new SetAssignedUserModel(id, new Guid(assignedUser.Id), assignedUser.FullName, assignedUser.EmailAddress)); TempData.SetNotification(NotificationType.Success, "Done", "Project is assigned"); } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectNotes/Index.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectNotes/Index.cshtml index aeaf02222..1b8f3cf90 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectNotes/Index.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectNotes/Index.cshtml @@ -7,7 +7,7 @@ @section BeforeMain { - @Links.ProjectList.Index.BackText + @Links.ProjectList.Index.BackText } @if (Model.NewNote) @@ -26,14 +26,9 @@
} -@if (@Model.Project.AcademyTypeAndRoute.ToUpper() == AcademyTypeAndRoutes.FormAMat.RouteDescription().ToUpper()) -{ - -} -else -{ - -} + + +

Project notes

diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectNotes/Index.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectNotes/Index.cshtml.cs index ca38b57e8..529c24d2a 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectNotes/Index.cshtml.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectNotes/Index.cshtml.cs @@ -1,6 +1,8 @@ using Dfe.PrepareConversions.Data.Services; +using Dfe.PrepareConversions.Models; using Dfe.PrepareConversions.ViewModels; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Primitives; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -9,6 +11,9 @@ namespace Dfe.PrepareConversions.Pages.ProjectNotes; public class IndexModel : BaseAcademyConversionProjectPageModel { + public string ReturnPage { get; set; } + public string ReturnId { get; set; } + public IndexModel(IAcademyConversionProjectRepository repository) : base(repository) { } @@ -20,9 +25,20 @@ public IndexModel(IAcademyConversionProjectRepository repository) : base(reposit public override async Task OnGetAsync(int id) { - NewNote = (bool)(TempData["newNote"] ?? false); await base.OnGetAsync(id); + NewNote = (bool)(TempData["newNote"] ?? false); + + ReturnPage = @Links.ProjectList.Index.Page; + var returnToFormAMatMenu = TempData["returnToFormAMatMenu"] as bool?; + + if (Project.IsFormAMat && returnToFormAMatMenu.HasValue && returnToFormAMatMenu.Value) + { + ReturnId = Project.FormAMatProjectId.ToString(); + ReturnPage = @Links.FormAMat.OtherSchoolsInMat.Page; + TempData["returnToFormAMatMenu"] = true; + } + return Page(); } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/FormAMatProjectListRow.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/FormAMatProjectListRow.cshtml new file mode 100644 index 000000000..93fc7a65b --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/FormAMatProjectListRow.cshtml @@ -0,0 +1,39 @@ +@using Dfe.Academisation.ExtensionMethods +@using Dfe.PrepareConversions.TagHelpers +@model ProjectListRowViewModel + + + +

+ + @Model.Item.SchoolName + + URN: @Model.Item.SchoolURN +

+

+

Route: @Model.Item.TypeAndRoute.RouteDescription()
+
Application to join a trust: @Model.Item.NameOfTrust
+ @if (@Model.Item.LocalAuthority.IsEmpty() is false) + { +
Local authority: @Model.Item.LocalAuthority
+ } +

+ + +

+ @Model.Item.Status.Value +

+

+ + Project created date: @Model.Item.CreatedOn.ToDateString()
+
+ + @("Advisory board date: " + Model.Item.HeadTeacherBoardDate)
+
+ + Opening date: + @Model.Item.ProposedAcademyOpeningDate + +

+ + \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/FormAMatProjectListRow.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/FormAMatProjectListRow.cshtml.cs new file mode 100644 index 000000000..45be45349 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/FormAMatProjectListRow.cshtml.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace Dfe.PrepareConversions.Pages.Shared +{ + public class FormAMatProjectListRowModel : PageModel + { + public void OnGet() + { + } + } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_FormAMatProjectHeader.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_FormAMatProjectHeader.cshtml index 3235a698d..cc8b443c8 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_FormAMatProjectHeader.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_FormAMatProjectHeader.cshtml @@ -1,28 +1,29 @@ @model ProjectViewModel
-
-
-
-

- Important -

-
-
-

- You cannot currently use this service to create project templates for Form a MAT applications. You should use KIM instead. -

-
-
- URN @Model.SchoolURN -

- @Model.SchoolName -

-

- Route: Form a MAT -

-
+
+ Application ref: @Model.ApplicationReferenceNumber +

+ @Model.NameOfTrust +

+

+ Assigned to: -

- -
+ @if (Model.AssignedUser == null || string.IsNullOrWhiteSpace(Model?.AssignedUser.FullName)) + { + Empty + } + else + { + @Model.AssignedUser.FullName + } + + Change +

+

+ @Model.ProjectStatus +

+
+
+ +
diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_FormAMatProjectListRows.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_FormAMatProjectListRows.cshtml new file mode 100644 index 000000000..707642e63 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_FormAMatProjectListRows.cshtml @@ -0,0 +1,67 @@ +@using Dfe.Academisation.ExtensionMethods +@using Dfe.PrepareConversions.TagHelpers +@model List + +@{ + var index = 0; + + foreach (var project in Model) + { + var projectRow = project.Row(index); + + + var link = @Links.FormAMat.OtherSchoolsInMat.Page; + + + + +
+ Application Reference: + @projectRow.Item.ApplciationReference +
+
+ Region: + Empty + @projectRow.Item.Regions +
+
+ Local authority: + Unconfirmed + @projectRow.Item.LocalAuthorities +
+
+ Schools included @projectRow.Item.SchoolNames +
+
+ Assigned to: + Unassigned + @projectRow.Item.AssignedTo +
+ @{ + // Aggregating statuses + var aggregatedStatuses = project.Status + .GroupBy(s => s.Value) + .Select(g => new { Status = g.Key, Count = g.Count(), Colour = g.First().Colour }) + .ToList(); + + // Displaying aggregated statuses + foreach (var status in aggregatedStatuses) + { +
+ + @status.Count @status.Status + +
+ } + } + + + + index++; + } +} + diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_FormAMatSubMenu.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_FormAMatSubMenu.cshtml index 9d3096fbc..0317e3e57 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_FormAMatSubMenu.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_FormAMatSubMenu.cshtml @@ -5,20 +5,21 @@