-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1025 from DFE-Digital/feature/158735-Associate-FAM
Feature/158735 associate fam
- Loading branch information
Showing
17 changed files
with
483 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...pareConversions/Dfe.PrepareConversions.Data/Extensions/DictionaryQuerystringExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text.Encodings.Web; | ||
|
||
namespace Dfe.PrepareConversions.Data.Extensions | ||
{ | ||
public static class DictionaryQuerystringExtensions | ||
{ | ||
/// <summary> | ||
/// Converts a <see cref="IDictionary{string, string}" /> to an encoded querystring. | ||
/// </summary> | ||
/// <param name="parameters"> | ||
/// An <see cref="IDictionary{string, string}" /> containing parameter names (of | ||
/// <see cref="string" />) and values (of <see cref="string" />) | ||
/// </param> | ||
/// <param name="prefix">A <see cref="bool" /> defining whether the querystring should have a '?' prefix (default: true)</param> | ||
/// <param name="keepEmpty"> | ||
/// A <see cref="bool" /> defining whether keys with null/empty values should be kept (default: | ||
/// true) | ||
/// </param> | ||
/// <returns>A string representing the parameters combined, UrlEncoded and (optionally) prefixed ready to be used in a URI</returns> | ||
public static string ToQueryString(this IDictionary<string, string> parameters, bool prefix = true, | ||
bool keepEmpty = true) | ||
{ | ||
IList<string> parameterPairs = parameters | ||
.Where(x => keepEmpty || string.IsNullOrWhiteSpace(x.Value) is false) | ||
.Select(x => $"{Encode(x.Key)}={Encode(x.Value)}") | ||
.ToList(); | ||
|
||
var prefixContent = prefix ? "?" : string.Empty; | ||
|
||
return parameterPairs.Count > 0 | ||
? $"{prefixContent}{string.Join("&", parameterPairs)}" | ||
: string.Empty; | ||
|
||
string Encode(string x) | ||
{ | ||
return string.IsNullOrWhiteSpace(x) ? string.Empty : UrlEncoder.Default.Encode(x); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/SetFormAMatProjectReference.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace Dfe.PrepareConversions.Data.Models | ||
{ | ||
public class SetFormAMatProjectReference | ||
{ | ||
public int ProjectId { get; set; } | ||
public int FormAMatProjectId { get; set; } | ||
|
||
|
||
public SetFormAMatProjectReference() { } | ||
|
||
public SetFormAMatProjectReference( | ||
int projectId, | ||
int formAMatProjectId) | ||
{ | ||
ProjectId = projectId; | ||
FormAMatProjectId = formAMatProjectId; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...pareConversions/Dfe.PrepareConversions/Pages/NewProject/IsProjectAlreadyInPreprare.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
@page "/start-new-project/is-project-already-in-prepare" | ||
@using Dfe.PrepareConversions.Pages.Shared | ||
@model Dfe.PrepareConversions.Pages.SponsoredProject.IsProjectAlreadyInPreprareModel | ||
|
||
@{ | ||
Layout = "_Layout"; | ||
ViewBag.Title = (!ViewData.ModelState.IsValid ? "Error: " : "") + "Is the form a MAT/SAT project already in Prepare?"; | ||
var routeParams = new Dictionary<string, string> | ||
{ | ||
{ "urn", Request.Query["urn"] }, | ||
{ "ukprn", Request.Query["ukprn"] }, | ||
{ "hasSchoolApplied", Request.Query["hasSchoolApplied"] }, | ||
{ "isFormAMat" , Request.Query["isFormAMat"]}, | ||
{ "isProjectInPrepare" , Request.Query["isProjectInPrepare"]}, | ||
}; | ||
} | ||
|
||
@section BeforeMain | ||
{ | ||
<partial name="_BackLink" model="@(new BackLink(Links.NewProject.SchoolApply.Page, routeParams))" /> | ||
<partial name="_ErrorSummary" /> | ||
} | ||
|
||
|
||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<form method="post"> | ||
|
||
<input hidden="" type="text" name="returnToSummary" value="no"> | ||
<input type="hidden" asp-for="Urn" /> | ||
<input type="hidden" asp-for="HasSchoolApplied" /> | ||
<h1 class="govuk-heading-l" data-cy="select-heading">Is the form a MAT/SAT project already in Prepare?</h1> | ||
|
||
<div class="govuk-form-group" @ModelState.GetErrorStyleClass()> | ||
<div class="govuk-radios"> | ||
<div class="govuk-radios__item"> | ||
<input asp-for="IsProjectInPrepare" class="govuk-radios__input" type="radio" value="Yes" id="DoneYes" data-cy="select-legal-input-yes"> | ||
<label class="govuk-label govuk-radios__label" for="DoneYes"> | ||
Yes | ||
</label> | ||
</div> | ||
|
||
<div class="govuk-radios__item"> | ||
<input asp-for="IsProjectInPrepare" class="govuk-radios__input" type="radio" value="No" id="DoneNo" data-cy="select-legal-input-no"> | ||
<label class="govuk-label govuk-radios__label" for="DoneNo"> | ||
No | ||
</label> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<button class="govuk-button pt-3" data-module="govuk-button" data-cy="select-common-submitbutton"> | ||
Continue | ||
</button> | ||
</form> | ||
|
||
</div> |
69 changes: 69 additions & 0 deletions
69
...eConversions/Dfe.PrepareConversions/Pages/NewProject/IsProjectAlreadyInPreprare.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using Dfe.PrepareConversions.Data.Services; | ||
using Dfe.PrepareConversions.Models; | ||
using Dfe.PrepareConversions.Models.ProjectList; | ||
using Dfe.PrepareConversions.Services; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using Microsoft.IdentityModel.Tokens; | ||
using System.Threading.Tasks; | ||
using EstablishmentDto = Dfe.Academies.Contracts.V4.Establishments.EstablishmentDto; | ||
|
||
namespace Dfe.PrepareConversions.Pages.SponsoredProject; | ||
|
||
public class IsProjectAlreadyInPreprareModel : PageModel | ||
{ | ||
private readonly ErrorService _errorService; | ||
private readonly IGetEstablishment _getEstablishment; | ||
|
||
public IsProjectAlreadyInPreprareModel(IGetEstablishment getEstablishment, ErrorService errorService) | ||
{ | ||
_getEstablishment = getEstablishment; | ||
_errorService = errorService; | ||
} | ||
[BindProperty] | ||
public string IsFormAMat { get; set; } | ||
[BindProperty] | ||
public string HasSchoolApplied { get; set; } | ||
|
||
[BindProperty] | ||
public string IsProjectInPrepare { get; set; } | ||
|
||
public string Urn { get; set; } | ||
|
||
public async Task<IActionResult> OnGet(string urn, string isFormAMat, string hasSchoolApplied, string isProjectInPrepare) | ||
{ | ||
ProjectListFilters.ClearFiltersFrom(TempData); | ||
HasSchoolApplied = hasSchoolApplied; | ||
IsFormAMat = isFormAMat; | ||
IsProjectInPrepare = isProjectInPrepare ?? "yes"; // Default to Yes if not used backlink to access | ||
|
||
EstablishmentDto establishment = await _getEstablishment.GetEstablishmentByUrn(urn); | ||
Urn = establishment.Urn; | ||
|
||
return Page(); | ||
} | ||
|
||
public async Task<IActionResult> OnPost(string ukprn, string urn, string redirect) | ||
{ | ||
|
||
if (IsProjectInPrepare.IsNullOrEmpty()) | ||
{ | ||
_errorService.AddError("Does project exists", "Select yes if the project already exists in Prepare"); | ||
return Page(); | ||
} | ||
string nextPage = null; | ||
if (IsProjectInPrepare.ToLower() == "yes") | ||
{ | ||
nextPage = Links.NewProject.LinkFormAMatProject.Page; | ||
} | ||
else | ||
{ | ||
nextPage = Links.NewProject.CreateNewFormAMat.Page; | ||
} | ||
|
||
|
||
redirect = string.IsNullOrEmpty(redirect) ? nextPage : redirect; | ||
|
||
return RedirectToPage(redirect, new { ukprn, urn, HasSchoolApplied, IsFormAMat, IsProjectInPrepare }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.