From c4f8c9d7eb7cfb53286fc01baa047d7810d8400b Mon Sep 17 00:00:00 2001 From: danielryannimble Date: Wed, 4 Sep 2024 15:17:17 +0100 Subject: [PATCH] benfefits and risk --- .../ComplexLandAndBuilding.cshtml | 42 ++++++ .../ComplexLandAndBuilding.cshtml.cs | 57 ++++++++ .../EqualitiesImpactAssessment.cshtml | 49 +++++++ .../EqualitiesImpactAssessment.cshtml.cs | 81 +++++++++++ .../BenefitsAndRisks/FinanceAndDebt.cshtml | 42 ++++++ .../BenefitsAndRisks/FinanceAndDebt.cshtml.cs | 60 ++++++++ .../HighProfileTransfer.cshtml | 46 ++++++ .../HighProfileTransfer.cshtml.cs | 53 +++++++ .../Projects/BenefitsAndRisks/Index.cshtml | 32 +++++ .../Projects/BenefitsAndRisks/Index.cshtml.cs | 92 ++++++++++++ .../BenefitsAndRisks/IntendedBenefits.cshtml | 80 +++++++++++ .../IntendedBenefits.cshtml.cs | 87 ++++++++++++ .../BenefitsAndRisks/OtherFactors.cshtml | 69 +++++++++ .../BenefitsAndRisks/OtherFactors.cshtml.cs | 131 ++++++++++++++++++ .../BenefitsAndRisks/OtherRisks.cshtml | 42 ++++++ .../BenefitsAndRisks/OtherRisks.cshtml.cs | 61 ++++++++ .../Projects/BenefitsAndRisks/Risks.cshtml | 49 +++++++ .../Projects/BenefitsAndRisks/Risks.cshtml.cs | 95 +++++++++++++ .../Pages/Projects/Rationale/Index.cshtml | 32 +++++ .../Pages/Projects/Rationale/Index.cshtml.cs | 55 ++++++++ .../Pages/Projects/Rationale/Project.cshtml | 52 +++++++ .../Projects/Rationale/Project.cshtml.cs | 57 ++++++++ .../Projects/Rationale/TrustOrSponsor.cshtml | 52 +++++++ .../Rationale/TrustOrSponsor.cshtml.cs | 57 ++++++++ .../Pages/Shared/_BenefitsSummary.cshtml | 98 +++++++++++++ .../Pages/Shared/_RationaleSummary.cshtml | 47 +++++++ .../Dfe.PrepareConversions.csproj | 2 +- 27 files changed, 1619 insertions(+), 1 deletion(-) create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/ComplexLandAndBuilding.cshtml create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/ComplexLandAndBuilding.cshtml.cs create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/EqualitiesImpactAssessment.cshtml create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/EqualitiesImpactAssessment.cshtml.cs create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/FinanceAndDebt.cshtml create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/FinanceAndDebt.cshtml.cs create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/HighProfileTransfer.cshtml create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/HighProfileTransfer.cshtml.cs create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/Index.cshtml create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/Index.cshtml.cs create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/IntendedBenefits.cshtml create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/IntendedBenefits.cshtml.cs create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/OtherFactors.cshtml create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/OtherFactors.cshtml.cs create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/OtherRisks.cshtml create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/OtherRisks.cshtml.cs create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/Risks.cshtml create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/Risks.cshtml.cs create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/Index.cshtml create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/Index.cshtml.cs create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/Project.cshtml create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/Project.cshtml.cs create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/TrustOrSponsor.cshtml create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/TrustOrSponsor.cshtml.cs create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Shared/_BenefitsSummary.cshtml create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Shared/_RationaleSummary.cshtml diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/ComplexLandAndBuilding.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/ComplexLandAndBuilding.cshtml new file mode 100644 index 000000000..9e79888ad --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/ComplexLandAndBuilding.cshtml @@ -0,0 +1,42 @@ +@page "/project/{urn}/benefits/land" +@using Dfe.PrepareTransfers.Web.Dfe.PrepareTransfers.Helpers.TagHelpers +@using Microsoft.AspNetCore.Mvc.TagHelpers +@model Dfe.PrepareTransfers.Web.Pages.Projects.BenefitsAndRisks.ComplexLandAndBuilding + +@{ + Layout = "_Layout"; + ViewBag.Title = "Complex land and building issues"; +} + +@section BeforeMain +{ + + Back + +} + +
+ +
+
+
+ + + +
+

+ +

+ +
+ +
+
+
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/ComplexLandAndBuilding.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/ComplexLandAndBuilding.cshtml.cs new file mode 100644 index 000000000..ba28fa3e3 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/ComplexLandAndBuilding.cshtml.cs @@ -0,0 +1,57 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Dfe.PrepareTransfers.Data; +using Dfe.PrepareTransfers.Data.Models.Projects; +using Dfe.PrepareTransfers.Web.Models; +using Microsoft.AspNetCore.Mvc; + +namespace Dfe.PrepareTransfers.Web.Pages.Projects.BenefitsAndRisks +{ + public class ComplexLandAndBuilding : CommonPageModel + { + private readonly IProjects _projectsRepository; + public string PreviousPage { get; set; } + [BindProperty] public string Answer { get; set; } + + public ComplexLandAndBuilding(IProjects projectsRepository) + { + _projectsRepository = projectsRepository; + } + + public async Task OnGetAsync() + { + var project = await _projectsRepository.GetByUrn(Urn); + var projectResult = project.Result; + Answer = projectResult.Benefits.OtherFactors[TransferBenefits.OtherFactor.ComplexLandAndBuildingIssues]; + IncomingTrustName = projectResult.IncomingTrustName; + PreviousPage = + OtherFactors.GetPage( + new List {TransferBenefits.OtherFactor.HighProfile}, + projectResult.Benefits.OtherFactors, true); + return Page(); + } + + public async Task OnPostAsync() + { + var project = await _projectsRepository.GetByUrn(Urn); + + var projectResult = project.Result; + projectResult.Benefits.OtherFactors[TransferBenefits.OtherFactor.ComplexLandAndBuildingIssues] = Answer ?? string.Empty; + + await _projectsRepository.UpdateBenefits(projectResult); + + if (ReturnToPreview) + { + return RedirectToPage(Links.HeadteacherBoard.Preview.PageName, new {Urn}); + } + + var available = new List + { + TransferBenefits.OtherFactor.FinanceAndDebtConcerns, + TransferBenefits.OtherFactor.OtherRisks + }; + + return RedirectToPage(OtherFactors.GetPage(available, projectResult.Benefits.OtherFactors), new {Urn}); + } + } +} \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/EqualitiesImpactAssessment.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/EqualitiesImpactAssessment.cshtml new file mode 100644 index 000000000..067b63f18 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/EqualitiesImpactAssessment.cshtml @@ -0,0 +1,49 @@ +@page "/project/{urn}/benefits/equalities-impact-assessment" +@using Microsoft.AspNetCore.Mvc.TagHelpers +@using Dfe.PrepareTransfers.Web.Dfe.PrepareTransfers.Helpers.TagHelpers +@model Dfe.PrepareTransfers.Web.Pages.Projects.BenefitsAndRisks.EqualitiesImpactAssessment + +@{ + ViewBag.Title = (!ViewData.ModelState.IsValid ? "Error: " : "") + "Has an Equalities Impact Assessment been considered?"; + Layout = "_Layout"; + + var formClasses = ViewData.ModelState.IsValid ? string.Empty : "govuk-form-group--error"; +} + +@section BeforeMain +{ + + Back + +} + +
+ +
+
+
+ + + +
+
+ +

+ + @Model.IncomingTrustName + + Has an Equalities Impact Assessment been considered? +

+
+ +

+ + +
+
+ +
+
+
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/EqualitiesImpactAssessment.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/EqualitiesImpactAssessment.cshtml.cs new file mode 100644 index 000000000..0415e40f6 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/EqualitiesImpactAssessment.cshtml.cs @@ -0,0 +1,81 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Dfe.PrepareTransfers.Data; +using Dfe.PrepareTransfers.Web.Models; +using Dfe.PrepareTransfers.Web.Models.Benefits; +using Dfe.PrepareTransfers.Web.Models.Forms; +using Microsoft.AspNetCore.Mvc; + +namespace Dfe.PrepareTransfers.Web.Pages.Projects.BenefitsAndRisks +{ + public class EqualitiesImpactAssessment : CommonPageModel + { + private readonly IProjects _projects; + + public EqualitiesImpactAssessment(IProjects projects) + { + _projects = projects; + } + + [BindProperty] public EqualitiesImpactAssessmentViewModel EqualitiesImpactAssessmentViewModel { get; set; } = new EqualitiesImpactAssessmentViewModel(); + + public IList RadioButtonsYesNo { get; set; } + + + public async Task OnGetAsync() + { + var project = await _projects.GetByUrn(Urn); + IncomingTrustName = project.Result.IncomingTrustName; + + RadioButtonsYesNo = GetRadioButtons(project.Result.Benefits.EqualitiesImpactAssessmentConsidered); + return Page(); + } + + public async Task OnPostAsync() + { + var project = await _projects.GetByUrn(Urn); + + if (!ModelState.IsValid) + { + RadioButtonsYesNo = GetRadioButtons(project.Result.Benefits.EqualitiesImpactAssessmentConsidered); + return Page(); + } + + project.Result.Benefits.EqualitiesImpactAssessmentConsidered = EqualitiesImpactAssessmentViewModel.EqualitiesImpactAssessmentConsidered; + await _projects.UpdateBenefits(project.Result); + + return RedirectToPage("/Projects/BenefitsAndRisks/Index", new {Urn}); + } + + private IList GetRadioButtons(bool? valueSelected) + { + var list = new List + { + new RadioButtonViewModel + { + DisplayName = "Yes", + Name = $"{nameof(EqualitiesImpactAssessmentViewModel.EqualitiesImpactAssessmentConsidered)}", + Value = "true", + Checked = valueSelected is true + }, + new RadioButtonViewModel + { + DisplayName = "No", + Name = $"{nameof(EqualitiesImpactAssessmentViewModel.EqualitiesImpactAssessmentConsidered)}", + Value = "false", + Checked = valueSelected is false + } + }; + + var selectedRadio = + list.FirstOrDefault(c => c.Value == EqualitiesImpactAssessmentViewModel.EqualitiesImpactAssessmentConsidered.ToString()); + if (selectedRadio != null) + { + selectedRadio.Checked = true; + } + + return list; + } + } +} \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/FinanceAndDebt.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/FinanceAndDebt.cshtml new file mode 100644 index 000000000..cb55acd92 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/FinanceAndDebt.cshtml @@ -0,0 +1,42 @@ +@page "/project/{urn}/benefits/finance" +@using Dfe.PrepareTransfers.Web.Dfe.PrepareTransfers.Helpers.TagHelpers +@using Microsoft.AspNetCore.Mvc.TagHelpers +@model Dfe.PrepareTransfers.Web.Pages.Projects.BenefitsAndRisks.FinanceAndDebt + +@{ + Layout = "_Layout"; + ViewBag.Title = "Finance and debt concerns"; +} + +@section BeforeMain +{ + + Back + +} + +
+ +
+
+
+ + + +
+

+ +

+ +
+ +
+
+
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/FinanceAndDebt.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/FinanceAndDebt.cshtml.cs new file mode 100644 index 000000000..c169cc2a7 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/FinanceAndDebt.cshtml.cs @@ -0,0 +1,60 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Dfe.PrepareTransfers.Data; +using Dfe.PrepareTransfers.Data.Models.Projects; +using Dfe.PrepareTransfers.Web.Models; +using Microsoft.AspNetCore.Mvc; + +namespace Dfe.PrepareTransfers.Web.Pages.Projects.BenefitsAndRisks +{ + public class FinanceAndDebt : CommonPageModel + { + private readonly IProjects _projectsRepository; + + [BindProperty] public string Answer { get; set; } + public string PreviousPage { get; set; } + + public FinanceAndDebt(IProjects projectsRepository) + { + _projectsRepository = projectsRepository; + } + + public async Task OnGetAsync() + { + var project = await _projectsRepository.GetByUrn(Urn); + + var projectResult = project.Result; + Answer = projectResult.Benefits.OtherFactors[TransferBenefits.OtherFactor.FinanceAndDebtConcerns]; + IncomingTrustName = projectResult.IncomingTrustName; + PreviousPage = + OtherFactors.GetPage( + new List + { + TransferBenefits.OtherFactor.ComplexLandAndBuildingIssues, + TransferBenefits.OtherFactor.HighProfile, + }, + projectResult.Benefits.OtherFactors, true); + return Page(); + } + + + public async Task OnPostAsync() + { + var project = await _projectsRepository.GetByUrn(Urn); + var projectResult = project.Result; + projectResult.Benefits.OtherFactors[TransferBenefits.OtherFactor.FinanceAndDebtConcerns] = Answer ?? string.Empty; + await _projectsRepository.UpdateBenefits(projectResult); + + if (ReturnToPreview) + { + return RedirectToPage(Links.HeadteacherBoard.Preview.PageName, new {Urn}); + } + + var available = new List + { + TransferBenefits.OtherFactor.OtherRisks + }; + return RedirectToPage(OtherFactors.GetPage(available, projectResult.Benefits.OtherFactors), new {Urn}); + } + } +} \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/HighProfileTransfer.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/HighProfileTransfer.cshtml new file mode 100644 index 000000000..6593238ed --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/HighProfileTransfer.cshtml @@ -0,0 +1,46 @@ +@page "/project/{urn}/benefits/high-profile-transfer" +@using Dfe.PrepareTransfers.Web.Dfe.PrepareTransfers.Helpers.TagHelpers +@using Microsoft.AspNetCore.Mvc.TagHelpers +@model Dfe.PrepareTransfers.Web.Pages.Projects.BenefitsAndRisks.HighProfileTransfer + +@{ + Layout = "_Layout"; + ViewBag.Title = "High profile transfer"; +} + +@section BeforeMain +{ + + Back + +} + +
+ +
+
+
+ + + +
+ +

+ +

+
+ For example, ministers and media could be involved. +
+ +
+ +
+
+
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/HighProfileTransfer.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/HighProfileTransfer.cshtml.cs new file mode 100644 index 000000000..3fe016970 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/HighProfileTransfer.cshtml.cs @@ -0,0 +1,53 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Dfe.PrepareTransfers.Data; +using Dfe.PrepareTransfers.Data.Models.Projects; +using Dfe.PrepareTransfers.Web.Models; +using Microsoft.AspNetCore.Mvc; + +namespace Dfe.PrepareTransfers.Web.Pages.Projects.BenefitsAndRisks +{ + public class HighProfileTransfer : CommonPageModel + { + private readonly IProjects _projectsRepository; + + [BindProperty] public string Answer { get; set; } + + public HighProfileTransfer(IProjects projectsRepository) + { + _projectsRepository = projectsRepository; + } + + public async Task OnGetAsync() + { + var project = await _projectsRepository.GetByUrn(Urn); + + var projectResult = project.Result; + IncomingTrustName = projectResult.IncomingTrustName; + Answer = projectResult.Benefits.OtherFactors[TransferBenefits.OtherFactor.HighProfile]; + return Page(); + } + + public async Task OnPostAsync() + { + var project = await _projectsRepository.GetByUrn(Urn); + + var projectResult = project.Result; + projectResult.Benefits.OtherFactors[TransferBenefits.OtherFactor.HighProfile] = Answer ?? string.Empty; + await _projectsRepository.UpdateBenefits(projectResult); + + if (ReturnToPreview) + { + return RedirectToPage(Links.HeadteacherBoard.Preview.PageName, new {Urn}); + } + + var available = new List + { + TransferBenefits.OtherFactor.ComplexLandAndBuildingIssues, + TransferBenefits.OtherFactor.FinanceAndDebtConcerns, + TransferBenefits.OtherFactor.OtherRisks + }; + return RedirectToPage(OtherFactors.GetPage(available, projectResult.Benefits.OtherFactors), new {Urn}); + } + } +} \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/Index.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/Index.cshtml new file mode 100644 index 000000000..2ca2a9978 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/Index.cshtml @@ -0,0 +1,32 @@ +@page "/project/{urn}/benefits" + +@using Microsoft.AspNetCore.Mvc.TagHelpers +@model Dfe.PrepareTransfers.Web.Pages.Projects.BenefitsAndRisks.Index +@{ + ViewBag.Title = "Benefits and risks"; + Layout = "_Layout"; +} + +@section BeforeMain +{ + Back +} + +
+
+ + Project reference: @Model.ProjectReference + +

+ Benefits and risks +

+
+
+
+ +
+
+ + +
+
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/Index.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/Index.cshtml.cs new file mode 100644 index 000000000..04b2a4fbe --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/Index.cshtml.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Dfe.PrepareTransfers.Data; +using Dfe.PrepareTransfers.Data.Models; +using Dfe.PrepareTransfers.Data.Models.Projects; +using Dfe.PrepareTransfers.Web.Models; +using Dfe.PrepareTransfers.Web.Models.Benefits; +using Microsoft.AspNetCore.Mvc; + +namespace Dfe.PrepareTransfers.Web.Pages.Projects.BenefitsAndRisks +{ + public class Index : CommonPageModel + { + private readonly IProjects _projects; + public BenefitsSummaryViewModel BenefitsSummaryViewModel { get; private set; } + + [BindProperty] + public MarkSectionCompletedViewModel MarkSectionCompletedViewModel { get; set; } + + public Index(IProjects projects) + { + _projects = projects; + } + + public async Task OnGetAsync() + { + var project = await _projects.GetByUrn(Urn); + + var projectResult = project.Result; + ProjectReference = projectResult.Reference; + BenefitsSummaryViewModel = new BenefitsSummaryViewModel( + projectResult.Benefits.IntendedBenefits.ToList(), + projectResult.Benefits.OtherIntendedBenefit, + BuildOtherFactorsItemViewModel(projectResult.Benefits.OtherFactors).Where(o => o.Checked).ToList(), + projectResult.Urn, + projectResult.OutgoingAcademyUrn, + projectResult.Benefits.AnyRisks, + projectResult.Benefits.EqualitiesImpactAssessmentConsidered + ); + MarkSectionCompletedViewModel = new MarkSectionCompletedViewModel + { + IsCompleted = projectResult.Benefits.IsCompleted ?? false, + ShowIsCompleted = BenefitsSectionDataIsPopulated(projectResult) + }; + + return Page(); + } + + public async Task OnPostAsync() + { + var project = await _projects.GetByUrn(Urn); + + var projectResult = project.Result; + + projectResult.Benefits.IsCompleted = MarkSectionCompletedViewModel.IsCompleted; + + await _projects.UpdateBenefits(projectResult); + + return RedirectToPage(ReturnToPreview ? Links.HeadteacherBoard.Preview.PageName : "/Projects/Index", + new {Urn}); + } + + private static bool BenefitsSectionDataIsPopulated(Project project) => + project.Benefits.IntendedBenefits != null + && project.Benefits.IntendedBenefits.Any() + && (project.Benefits.OtherFactors != null && project.Benefits.OtherFactors.Any() || project.Benefits.AnyRisks == false); + + public static List BuildOtherFactorsItemViewModel( + Dictionary otherFactorsToSet) + { + List items = new List(); + foreach (TransferBenefits.OtherFactor otherFactor in Enum.GetValues(typeof(TransferBenefits.OtherFactor))) + { + if (otherFactor != TransferBenefits.OtherFactor.Empty) + { + var isChecked = otherFactorsToSet.ContainsKey(otherFactor); + + items.Add(new OtherFactorsItemViewModel() + { + OtherFactor = otherFactor, + Checked = isChecked, + Description = isChecked ? otherFactorsToSet[otherFactor] : string.Empty + }); + } + } + + return items; + } + } +} \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/IntendedBenefits.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/IntendedBenefits.cshtml new file mode 100644 index 000000000..227da2cf4 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/IntendedBenefits.cshtml @@ -0,0 +1,80 @@ +@page "/project/{urn}/benefits/intended-benefits" +@model Dfe.PrepareTransfers.Web.Pages.Projects.BenefitsAndRisks.IntendedBenefits + +@using Dfe.PrepareTransfers.Data.Models.Projects +@using Dfe.PrepareTransfers.Web.Dfe.PrepareTransfers.Helpers.TagHelpers +@using Microsoft.AspNetCore.Mvc.ModelBinding +@using Microsoft.AspNetCore.Mvc.TagHelpers + +@{ + ViewBag.Title = (!ViewData.ModelState.IsValid ? "Error: " : "") + "What are the intended benefits of the transfer?"; + Layout = "_Layout"; + var formClasses = ViewData.ModelState.GetFieldValidationState($"{nameof(Model.IntendedBenefitsViewModel)}.{nameof(Model.IntendedBenefitsViewModel.SelectedIntendedBenefits)}") == ModelValidationState.Invalid ? "govuk-form-group--error" : ""; + var otherBenefitFormClasses = ViewData.ModelState.GetFieldValidationState($"{nameof(Model.IntendedBenefitsViewModel)}.{nameof(Model.IntendedBenefitsViewModel.OtherBenefit)}") == ModelValidationState.Invalid ? "govuk-form-group--error" : ""; +} + +@section BeforeMain +{ + + Back + +} + +
+ +
+
+
+ + + +
+
+ +

+ + @Model.IncomingTrustName + + What are the intended benefits of the transfer? +

+
+
+ Select all that apply. +
+ +

+ +
+ + + + @{ + var otherBenefit = TransferBenefits.IntendedBenefit.Other.ToString(); + } + +
+ + +
+
+
+ + +

+ + +
+
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/IntendedBenefits.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/IntendedBenefits.cshtml.cs new file mode 100644 index 000000000..fbcb6579d --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/IntendedBenefits.cshtml.cs @@ -0,0 +1,87 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Dfe.PrepareTransfers.Data; +using Dfe.PrepareTransfers.Data.Models.Projects; +using Dfe.PrepareTransfers.Web.Models; +using Dfe.PrepareTransfers.Web.Models.Benefits; +using Dfe.PrepareTransfers.Web.Models.Forms; +using Dfe.PrepareTransfers.Helpers; +using Microsoft.AspNetCore.Mvc; + +namespace Dfe.PrepareTransfers.Web.Pages.Projects.BenefitsAndRisks +{ + public class IntendedBenefits : CommonPageModel + { + private readonly IProjects _projects; + + [BindProperty] + public IntendedBenefitsViewModel IntendedBenefitsViewModel { get; set; } = new IntendedBenefitsViewModel(); + + public IList Checkboxes { get; set; } + + public IntendedBenefits(IProjects projects) + { + _projects = projects; + } + + public async Task OnGetAsync() + { + var project = await _projects.GetByUrn(Urn); + + var projectResult = project.Result; + + IncomingTrustName = projectResult.IncomingTrustName; + IntendedBenefitsViewModel.SelectedIntendedBenefits = projectResult.Benefits.IntendedBenefits; + IntendedBenefitsViewModel.OtherBenefit = + projectResult.Benefits.IntendedBenefits.Contains(TransferBenefits.IntendedBenefit.Other) + ? projectResult.Benefits.OtherIntendedBenefit + : null; + Checkboxes = GetIntendedBenefitsCheckboxes(); + return Page(); + } + + private IList GetIntendedBenefitsCheckboxes() + { + IList items = new List(); + foreach (var intendedBenefit in EnumHelpers.GetDisplayableValues( + TransferBenefits.IntendedBenefit.Empty)) + { + items.Add(new CheckboxViewModel + { + DisplayName = EnumHelpers.GetDisplayValue(intendedBenefit), + Name = + $"{nameof(IntendedBenefitsViewModel)}.{nameof(IntendedBenefitsViewModel.SelectedIntendedBenefits)}", + Value = intendedBenefit.ToString(), + Checked = IntendedBenefitsViewModel.SelectedIntendedBenefits.Contains(intendedBenefit) + }); + } + + return items; + } + + public async Task OnPostAsync() + { + var project = await _projects.GetByUrn(Urn); + + if (!ModelState.IsValid) + { + Checkboxes = GetIntendedBenefitsCheckboxes(); + return Page(); + } + + var projectResult = project.Result; + projectResult.Benefits.IntendedBenefits = + new List(IntendedBenefitsViewModel.SelectedIntendedBenefits); + projectResult.Benefits.OtherIntendedBenefit = IntendedBenefitsViewModel.OtherBenefit; + + await _projects.UpdateBenefits(projectResult); + + if (ReturnToPreview) + { + return RedirectToPage(Links.HeadteacherBoard.Preview.PageName, new {Urn}); + } + + return RedirectToPage("/Projects/BenefitsAndRisks/Index", new {Urn}); + } + } +} \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/OtherFactors.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/OtherFactors.cshtml new file mode 100644 index 000000000..39f8e98f9 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/OtherFactors.cshtml @@ -0,0 +1,69 @@ +@page "/project/{urn}/benefits/other-factors" +@model Dfe.PrepareTransfers.Web.Pages.Projects.BenefitsAndRisks.OtherFactors + +@using Dfe.PrepareTransfers.Data.Models.Projects +@using Dfe.PrepareTransfers.Helpers +@using Dfe.PrepareTransfers.Web.Dfe.PrepareTransfers.Helpers.TagHelpers +@using Microsoft.AspNetCore.Mvc.ModelBinding +@using Microsoft.AspNetCore.Mvc.TagHelpers + +@{ + ViewBag.Title = (!ViewData.ModelState.IsValid ? "Error: " : "") + "What are the risks with this transfer?"; + Layout = "_Layout"; + var formClasses = ViewData.ModelState.GetFieldValidationState(nameof(Model.OtherFactorsViewModel.OtherFactorsVm)) == ModelValidationState.Invalid ? "govuk-form-group--error" : ""; +} + +@section BeforeMain +{ + + Back + +} + +
+ +
+
+
+ + + +
+
+ +

+ + @Model.IncomingTrustName + + What are the risks with this transfer? +

+
+
+ Select all that apply. +
+ +
+ @for (var i = 0; i < Model.OtherFactorsViewModel.OtherFactorsVm.Count; i++) + { + var checkBox = Model.OtherFactorsViewModel.OtherFactorsVm[i]; + var nameOrValue = i == 0 ? nameof(Model.OtherFactorsViewModel) : checkBox.OtherFactor.ToString(); +
+ + +
+ + } +
+
+
+ +
+
+
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/OtherFactors.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/OtherFactors.cshtml.cs new file mode 100644 index 000000000..1d11936a0 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/OtherFactors.cshtml.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Dfe.PrepareTransfers.Data; +using Dfe.PrepareTransfers.Data.Models.Projects; +using Dfe.PrepareTransfers.Web.Models; +using Dfe.PrepareTransfers.Web.Models.Benefits; +using Microsoft.AspNetCore.Mvc; + +// ReSharper disable UnusedMember.Global - properties bound using [BindProperty] + +namespace Dfe.PrepareTransfers.Web.Pages.Projects.BenefitsAndRisks +{ + public class OtherFactors : CommonPageModel + { + private readonly IProjects _projects; + + public OtherFactors(IProjects projects) + { + _projects = projects; + } + + [BindProperty] public OtherFactorsViewModel OtherFactorsViewModel { get; set; } = new OtherFactorsViewModel(); + + public async Task OnGetAsync() + { + var project = await _projects.GetByUrn(Urn); + + var projectResult = project.Result; + IncomingTrustName = projectResult.IncomingTrustName; + OtherFactorsViewModel.OtherFactorsVm = BuildOtherFactorsItemViewModel(projectResult.Benefits.OtherFactors); + + return Page(); + } + + public async Task OnPostAsync() + { + var project = await _projects.GetByUrn(Urn); + var projectResult = project.Result; + + if (!ModelState.IsValid) + { + return Page(); + } + + projectResult.Benefits.OtherFactors = OtherFactorsViewModel.OtherFactorsVm + .Where(of => of.Checked) + .ToDictionary(d => d.OtherFactor, x => x.Description); + await _projects.UpdateBenefits(projectResult); + + var available = new List + + { + TransferBenefits.OtherFactor.HighProfile, + TransferBenefits.OtherFactor.ComplexLandAndBuildingIssues, + TransferBenefits.OtherFactor.FinanceAndDebtConcerns, + TransferBenefits.OtherFactor.OtherRisks + }; + return RedirectToPage(GetPage(available, projectResult.Benefits.OtherFactors), new {Urn}); + } + + /// + /// Get next or previous page for other factors dynamic navigation + /// + /// List of other factors to navigate to + /// Other factors currently selected + /// true if navigating backwards, back link + /// Page name + public static string GetPage(List available, + Dictionary otherFactors, bool backLink = false) + { + var foundOtherFactor = + available.FirstOrDefault(otherFactor => otherFactors.Select(o => o.Key).Contains(otherFactor)); + + string backLinkContent = + backLink ? "/Projects/BenefitsAndRisks/OtherFactors" : "/Projects/BenefitsAndRisks/Index"; + + var pageUrl = GetPageUrlFromOtherFactor(foundOtherFactor); + + return string.IsNullOrEmpty(pageUrl) ? backLinkContent : pageUrl; + } + + public static string GetPageUrlFromOtherFactor(TransferBenefits.OtherFactor foundOtherFactor) + { + switch (foundOtherFactor) + { + case TransferBenefits.OtherFactor.HighProfile: + { + return "/Projects/BenefitsAndRisks/HighProfileTransfer"; + } + case TransferBenefits.OtherFactor.ComplexLandAndBuildingIssues: + { + return "/Projects/BenefitsAndRisks/ComplexLandAndBuilding"; + } + case TransferBenefits.OtherFactor.FinanceAndDebtConcerns: + { + return "/Projects/BenefitsAndRisks/FinanceAndDebt"; + } + case TransferBenefits.OtherFactor.OtherRisks: + { + return "/Projects/BenefitsAndRisks/OtherRisks"; + } + } + + return null; + } + + public static List BuildOtherFactorsItemViewModel( + Dictionary otherFactorsToSet) + { + List items = new List(); + foreach (TransferBenefits.OtherFactor otherFactor in Enum.GetValues(typeof(TransferBenefits.OtherFactor))) + { + if (otherFactor != TransferBenefits.OtherFactor.Empty) + { + var isChecked = otherFactorsToSet.ContainsKey(otherFactor); + + items.Add(new OtherFactorsItemViewModel + { + Description = isChecked ? otherFactorsToSet[otherFactor] : null, + OtherFactor = otherFactor, + Checked = isChecked + }); + } + } + + return items; + } + } +} \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/OtherRisks.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/OtherRisks.cshtml new file mode 100644 index 000000000..c301db2ab --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/OtherRisks.cshtml @@ -0,0 +1,42 @@ +@page "/project/{urn}/benefits/other-risks" +@using Dfe.PrepareTransfers.Web.Dfe.PrepareTransfers.Helpers.TagHelpers +@using Microsoft.AspNetCore.Mvc.TagHelpers +@model Dfe.PrepareTransfers.Web.Pages.Projects.BenefitsAndRisks.OtherRisks + +@{ + Layout = "_Layout"; + ViewBag.Title = "Other risks"; +} + +@section BeforeMain +{ + + Back + +} + +
+ +
+
+
+ + + +
+ + +
+ +
+
+
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/OtherRisks.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/OtherRisks.cshtml.cs new file mode 100644 index 000000000..636519bf7 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/OtherRisks.cshtml.cs @@ -0,0 +1,61 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Dfe.PrepareTransfers.Data; +using Dfe.PrepareTransfers.Data.Models.Projects; +using Dfe.PrepareTransfers.Web.Models; +using Microsoft.AspNetCore.Mvc; + +namespace Dfe.PrepareTransfers.Web.Pages.Projects.BenefitsAndRisks +{ + public class OtherRisks : CommonPageModel + { + private readonly IProjects _projectsRepository; + [BindProperty] public string Answer { get; set; } + + public string PreviousPage { get; set; } + + public OtherRisks(IProjects projectsRepository) + { + _projectsRepository = projectsRepository; + } + + public async Task OnGetAsync() + { + var project = await _projectsRepository.GetByUrn(Urn); + var projectResult = project.Result; + IncomingTrustName = projectResult.IncomingTrustName; + Answer = projectResult.Benefits.OtherFactors[TransferBenefits.OtherFactor.OtherRisks]; + PreviousPage = + OtherFactors.GetPage( + new List + { + TransferBenefits.OtherFactor.ComplexLandAndBuildingIssues, + TransferBenefits.OtherFactor.HighProfile, + TransferBenefits.OtherFactor.FinanceAndDebtConcerns + }, + projectResult.Benefits.OtherFactors, true); + return Page(); + } + + public async Task OnPostAsync() + { + var project = await _projectsRepository.GetByUrn(Urn); + + if (!ModelState.IsValid) + { + return Page(); + } + + var projectResult = project.Result; + projectResult.Benefits.OtherFactors[TransferBenefits.OtherFactor.OtherRisks] = Answer ?? string.Empty; + await _projectsRepository.UpdateBenefits(projectResult); + + if (ReturnToPreview) + { + return RedirectToPage(Links.HeadteacherBoard.Preview.PageName, new {Urn}); + } + + return RedirectToPage("/Projects/BenefitsAndRisks/Index", new {Urn}); + } + } +} \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/Risks.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/Risks.cshtml new file mode 100644 index 000000000..864398925 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/Risks.cshtml @@ -0,0 +1,49 @@ +@page "/project/{urn}/benefits/risks" +@using Microsoft.AspNetCore.Mvc.ModelBinding +@using Microsoft.AspNetCore.Mvc.TagHelpers +@using Dfe.PrepareTransfers.Web.Dfe.PrepareTransfers.Helpers.TagHelpers +@model Dfe.PrepareTransfers.Web.Pages.Projects.BenefitsAndRisks.Risks + +@{ + ViewBag.Title = (!ViewData.ModelState.IsValid ? "Error: " : "") + "Are there any risks to consider for this transfer?"; + Layout = "_Layout"; + var formClasses = ViewData.ModelState.GetFieldValidationState($"{nameof(Model.RisksViewModel)}.{nameof(Model.RisksViewModel.RisksInvolved)}") == ModelValidationState.Invalid ? "govuk-form-group--error" : ""; +} + +@section BeforeMain +{ + + Back + +} + +
+ +
+
+
+ + + +
+
+ +

+ + @Model.IncomingTrustName + + Are there any risks to consider? +

+
+ +

+ + +
+
+ +
+
+
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/Risks.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/Risks.cshtml.cs new file mode 100644 index 000000000..981aa1340 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/BenefitsAndRisks/Risks.cshtml.cs @@ -0,0 +1,95 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Dfe.PrepareTransfers.Data; +using Dfe.PrepareTransfers.Data.Models.Projects; +using Dfe.PrepareTransfers.Web.Models; +using Dfe.PrepareTransfers.Web.Models.Benefits; +using Dfe.PrepareTransfers.Web.Models.Forms; +using Microsoft.AspNetCore.Mvc; + +namespace Dfe.PrepareTransfers.Web.Pages.Projects.BenefitsAndRisks +{ + public class Risks : CommonPageModel + { + private readonly IProjects _projects; + + public Risks(IProjects projects) + { + _projects = projects; + } + + [BindProperty] public RisksViewModel RisksViewModel { get; set; } = new RisksViewModel(); + + public IList RadioButtonsYesNo { get; set; } + + + public async Task OnGetAsync() + { + var project = await _projects.GetByUrn(Urn); + RadioButtonsYesNo = GetRadioButtons(project.Result.Benefits.AnyRisks); + return Page(); + } + + public async Task OnPostAsync() + { + var project = await _projects.GetByUrn(Urn); + + if (!ModelState.IsValid) + { + RadioButtonsYesNo = GetRadioButtons(project.Result.Benefits.AnyRisks); + return Page(); + } + + var originalAnswer = project.Result.Benefits.AnyRisks; + project.Result.Benefits.AnyRisks = RisksViewModel.RisksInvolved; + if (RisksViewModel.RisksInvolved == false) + { + project.Result.Benefits.OtherFactors = new Dictionary(); + } + + await _projects.UpdateBenefits(project.Result); + + //Only go back to preview if No,or no change. Changing to Yes will take them through the options + if (ReturnToPreview && RisksViewModel.RisksInvolved == false || + ReturnToPreview && RisksViewModel.RisksInvolved == true && originalAnswer == true) + { + return RedirectToPage(Links.HeadteacherBoard.Preview.PageName, new {Urn}); + } + + return RisksViewModel.RisksInvolved == true + ? RedirectToPage("/Projects/BenefitsAndRisks/OtherFactors", new {Urn}) + : RedirectToPage("/Projects/BenefitsAndRisks/Index", new {Urn}); + } + + private IList GetRadioButtons(bool? valueSelected) + { + var list = new List + { + new RadioButtonViewModel + { + DisplayName = "Yes", + Name = $"{nameof(RisksViewModel.RisksInvolved)}", + Value = "true", + Checked = valueSelected is true + }, + new RadioButtonViewModel + { + DisplayName = "No", + Name = $"{nameof(RisksViewModel.RisksInvolved)}", + Value = "false", + Checked = valueSelected is false + } + }; + + var selectedRadio = + list.FirstOrDefault(c => c.Value == RisksViewModel.RisksInvolved.ToString()); + if (selectedRadio != null) + { + selectedRadio.Checked = true; + } + + return list; + } + } +} \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/Index.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/Index.cshtml new file mode 100644 index 000000000..3deba9c1c --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/Index.cshtml @@ -0,0 +1,32 @@ +@page "/project/{urn}/rationale" +@using Microsoft.AspNetCore.Mvc.TagHelpers +@model Dfe.PrepareTransfers.Web.Pages.Projects.Rationale.Index + +@{ + ViewBag.Title = "Provide the rationale for the transfer"; + Layout = "_Layout"; +} + +@section BeforeMain +{ + Back +} + +
+
+ + Project reference: @Model.ProjectReference + +

+ Provide the rationale for the transfer +

+
+
+
+ +
+
+ + +
+
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/Index.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/Index.cshtml.cs new file mode 100644 index 000000000..c17fad11f --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/Index.cshtml.cs @@ -0,0 +1,55 @@ +using System.Threading.Tasks; +using Dfe.PrepareTransfers.Data; +using Dfe.PrepareTransfers.Web.Models; +using Microsoft.AspNetCore.Mvc; + +namespace Dfe.PrepareTransfers.Web.Pages.Projects.Rationale +{ + public class Index : CommonPageModel + { + public string ProjectRationale { get; set; } + public string TrustRationale { get; set; } + + private readonly IProjects _projects; + [BindProperty] + public MarkSectionCompletedViewModel MarkSectionCompletedViewModel { get; set; } + + public Index(IProjects projects) + { + _projects = projects; + } + + public async Task OnGetAsync() + { + var project = await _projects.GetByUrn(Urn); + + var projectResult = project.Result; + + ProjectReference = projectResult.Reference; + ProjectRationale = projectResult.Rationale.Project; + TrustRationale = projectResult.Rationale.Trust; + OutgoingAcademyUrn = projectResult.OutgoingAcademyUrn; + MarkSectionCompletedViewModel = new MarkSectionCompletedViewModel + { + IsCompleted = projectResult.Rationale.IsCompleted ?? false, + ShowIsCompleted = !string.IsNullOrEmpty(projectResult.Rationale.Project) && + !string.IsNullOrEmpty(projectResult.Rationale.Trust) + }; + return Page(); + } + + public async Task OnPostAsync() + { + var project = await _projects.GetByUrn(Urn); + + var projectResult = project.Result; + + projectResult.Rationale.IsCompleted = MarkSectionCompletedViewModel.IsCompleted; + + await _projects.UpdateRationale(projectResult); + + return RedirectToPage(ReturnToPreview ? Links.HeadteacherBoard.Preview.PageName : "/Projects/Index", + new {Urn}); + } + } +} \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/Project.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/Project.cshtml new file mode 100644 index 000000000..65a8adb04 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/Project.cshtml @@ -0,0 +1,52 @@ +@page "/project/{urn}/rationale/project" +@using Dfe.PrepareTransfers.Web.Dfe.PrepareTransfers.Helpers.TagHelpers +@using Microsoft.AspNetCore.Mvc.TagHelpers +@model Dfe.PrepareTransfers.Web.Pages.Projects.Rationale.Project + +@{ + ViewBag.Title = (!ViewData.ModelState.IsValid ? "Error: " : "") + "Write the rationale for the project"; + Layout = "_Layout"; + var formClasses = ViewData.ModelState.IsValid ? "" : "govuk-form-group--error"; +} + +@section BeforeMain +{ + + Back + +} + +
+ +
+
+
+ + + +
+ +
+ Use the school's rationale from the application as a basis for your analysis. +
+
+ You can format this section after you download your project template. +
+ +

+ + +
+ +
+
+
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/Project.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/Project.cshtml.cs new file mode 100644 index 000000000..9e3e01d57 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/Project.cshtml.cs @@ -0,0 +1,57 @@ +using System.Threading.Tasks; +using Dfe.PrepareTransfers.Data; +using Dfe.PrepareTransfers.Web.Models; +using Dfe.PrepareTransfers.Web.Models.Rationale; +using Microsoft.AspNetCore.Mvc; + +namespace Dfe.PrepareTransfers.Web.Pages.Projects.Rationale +{ + public class Project : CommonPageModel + { + private readonly IProjects _projectsRepository; + + public Project(IProjects projectsRepository) + { + _projectsRepository = projectsRepository; + } + + [BindProperty] public RationaleProjectViewModel ViewModel { get; set; } + + public async Task OnGetAsync() + { + var project = await _projectsRepository.GetByUrn(Urn); + + var projectResult = project.Result; + + IncomingTrustName = projectResult.IncomingTrustName; + ViewModel = new RationaleProjectViewModel + { + ProjectRationale = projectResult.Rationale.Project + }; + + return Page(); + } + + public async Task OnPostAsync() + { + var project = await _projectsRepository.GetByUrn(Urn); + + if (!ModelState.IsValid) + { + return Page(); + } + + var projectResult = project.Result; + projectResult.Rationale.Project = ViewModel.ProjectRationale; + + await _projectsRepository.UpdateRationale(projectResult); + + if (ReturnToPreview) + { + return RedirectToPage(Links.HeadteacherBoard.Preview.PageName, new {Urn}); + } + + return RedirectToPage("/Projects/Rationale/Index", new {Urn}); + } + } +} \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/TrustOrSponsor.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/TrustOrSponsor.cshtml new file mode 100644 index 000000000..2748ef7f1 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/TrustOrSponsor.cshtml @@ -0,0 +1,52 @@ +@page "/project/{urn}/rationale/trust-or-sponsor" +@using Dfe.PrepareTransfers.Web.Dfe.PrepareTransfers.Helpers.TagHelpers +@using Microsoft.AspNetCore.Mvc.TagHelpers +@model Dfe.PrepareTransfers.Web.Pages.Projects.Rationale.TrustOrSponsor + +@{ + ViewBag.Title = (!ViewData.ModelState.IsValid ? "Error: " : "") + "Write the rationale for the trust or sponsor"; + Layout = "_Layout"; + var formClasses = ViewData.ModelState.IsValid ? "" : "govuk-form-group--error"; +} + +@section BeforeMain +{ + + Back + +} + +
+ +
+
+
+ + + +
+ +
+ Explain why the trust is a good match for the school. +
+
+ You can format this section after you download your project template. +
+ +

+ + +
+ +
+
+
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/TrustOrSponsor.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/TrustOrSponsor.cshtml.cs new file mode 100644 index 000000000..30e940806 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/Rationale/TrustOrSponsor.cshtml.cs @@ -0,0 +1,57 @@ +using System.Threading.Tasks; +using Dfe.PrepareTransfers.Data; +using Dfe.PrepareTransfers.Web.Models; +using Dfe.PrepareTransfers.Web.Models.Rationale; +using Microsoft.AspNetCore.Mvc; + +namespace Dfe.PrepareTransfers.Web.Pages.Projects.Rationale +{ + public class TrustOrSponsor : CommonPageModel + { + private readonly IProjects _projectsRepository; + + [BindProperty] public RationaleTrustOrSponsorViewModel ViewModel { get; set; } + + public TrustOrSponsor(IProjects projectsRepository) + { + _projectsRepository = projectsRepository; + } + + public async Task OnGetAsync() + { + var project = await _projectsRepository.GetByUrn(Urn); + + var projectResult = project.Result; + + IncomingTrustName = projectResult.IncomingTrustName; + ViewModel = new RationaleTrustOrSponsorViewModel + { + TrustOrSponsorRationale = projectResult.Rationale.Trust + }; + + return Page(); + } + + public async Task OnPostAsync() + { + var project = await _projectsRepository.GetByUrn(Urn); + + if (!ModelState.IsValid) + { + return Page(); + } + + var projectResult = project.Result; + projectResult.Rationale.Trust = ViewModel.TrustOrSponsorRationale; + + await _projectsRepository.UpdateRationale(projectResult); + + if (ReturnToPreview) + { + return RedirectToPage(Links.HeadteacherBoard.Preview.PageName, new {Urn}); + } + + return RedirectToPage("/Projects/Rationale/Index", new {Urn}); + } + } +} \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Shared/_BenefitsSummary.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Shared/_BenefitsSummary.cshtml new file mode 100644 index 000000000..24535c1b3 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Shared/_BenefitsSummary.cshtml @@ -0,0 +1,98 @@ +@model Dfe.PrepareTransfers.Web.Models.Benefits.BenefitsSummaryViewModel +@using Dfe.PrepareTransfers.Helpers +@using Dfe.PrepareTransfers.Data.Models.Projects +@using Microsoft.AspNetCore.Mvc.TagHelpers +
+
+
+ What are the intended benefits of the transfer? +
+ @if (!Model.IntendedBenefitsSummary().Any()) + { +
+ Empty +
+ } + else + { +
+ @foreach (var benefit in Model.IntendedBenefitsSummary()) + { +

+ @benefit +

+ } +
+ } +
+ + Change the intended benefits of the transfer + +
+
+
+
+ Are there any risks to consider for this transfer? +
+
+ @if (!Model.AnyRisks.HasValue) + { + Empty + } + else + { +

@(Model.AnyRisks == true ? "Yes" : "No")

+ } +
+
+ + Change risks to consider + +
+
+ @foreach (var otherFactor in Model.OtherFactorsItems) + { + var label = (EnumHelpers.GetDisplayValue(otherFactor.OtherFactor)); +
+
+ @label +
+
+ @if (string.IsNullOrWhiteSpace(otherFactor.Description)) + { + Empty + } + else + { +

@otherFactor.Description

+ } +
+
+ + Change @label + + +
+
+ } +
+
+ Has an Equalities Impact Assessment been considered? +
+
+ @if (!Model.EqualitiesImpactAssessmentConsidered.HasValue) + { + Empty + } + else + { +

@(Model.EqualitiesImpactAssessmentConsidered == true ? "Yes" : "No")

+ } +
+
+ + Change equalities impact assessment + +
+
+
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Shared/_RationaleSummary.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Shared/_RationaleSummary.cshtml new file mode 100644 index 000000000..f5bd9e8f6 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Shared/_RationaleSummary.cshtml @@ -0,0 +1,47 @@ +@using Microsoft.AspNetCore.Mvc.TagHelpers +@model Dfe.PrepareTransfers.Web.Pages.Projects.Rationale.Index + +
+
+
+ What is the rationale for the project? +
+
+ @if (string.IsNullOrEmpty(Model.ProjectRationale)) + { + Empty + } + else + { + @Model.ProjectRationale + } +
+
+ + Change rationale for project + +
+
+
+
+ Why was the incoming trust or sponsor chosen? +
+
+ @if (string.IsNullOrEmpty(Model.TrustRationale)) + { + Empty + } + else + { + @Model.TrustRationale + } +
+
+ + Change rationale for the trust or sponsor + +
+
+
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Dfe.PrepareConversions.csproj b/Dfe.PrepareConversions/Dfe.PrepareConversions/Dfe.PrepareConversions.csproj index b25dfa033..3677e26e9 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Dfe.PrepareConversions.csproj +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Dfe.PrepareConversions.csproj @@ -1,7 +1,7 @@  net8.0 - eae6d8bd-2a58-4ed4-99e2-a82f32b0ce47 + e215616b-382a-4438-ad25-e2fc1629c6e5 ..\.sonarlint\dfe-digital_a2b-internalcsharp.ruleset