-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add check to see if user requesting a TRN is intending to do an NPQ
- Loading branch information
Showing
11 changed files
with
412 additions
and
60 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
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
15 changes: 15 additions & 0 deletions
15
...RecordSystem/src/TeachingRecordSystem.AuthorizeAccess/Pages/RequestTrn/NotEligible.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,15 @@ | ||
@page "/request-trn/not-eligible" | ||
@model TeachingRecordSystem.AuthorizeAccess.Pages.RequestTrn.NotEligibleModel | ||
@{ | ||
ViewBag.Title = "You cannot use this service to get a TRN"; | ||
} | ||
|
||
@section BeforeContent { | ||
<govuk-back-link href="@LinkGenerator.RequestTrnNpqCheck(Model.JourneyInstance!.InstanceId)" /> | ||
} | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds-from-desktop"> | ||
<h1 class="govuk-heading-l">@ViewBag.Title</h1> | ||
</div> | ||
</div> |
24 changes: 24 additions & 0 deletions
24
...ordSystem/src/TeachingRecordSystem.AuthorizeAccess/Pages/RequestTrn/NotEligible.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,24 @@ | ||
using Microsoft.AspNetCore.Mvc.Filters; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using TeachingRecordSystem.UiCommon.FormFlow; | ||
|
||
namespace TeachingRecordSystem.AuthorizeAccess.Pages.RequestTrn; | ||
|
||
[Journey(RequestTrnJourneyState.JourneyName), RequireJourneyInstance] | ||
public class NotEligibleModel(AuthorizeAccessLinkGenerator linkGenerator) : PageModel | ||
{ | ||
public JourneyInstance<RequestTrnJourneyState>? JourneyInstance { get; set; } | ||
|
||
public override void OnPageHandlerExecuting(PageHandlerExecutingContext context) | ||
{ | ||
var state = JourneyInstance!.State; | ||
if (state.HasPendingTrnRequest) | ||
{ | ||
context.Result = Redirect(linkGenerator.RequestTrnSubmitted(JourneyInstance!.InstanceId)); | ||
} | ||
else if (state.IsPlanningToTakeAnNpq is null) | ||
{ | ||
context.Result = Redirect(linkGenerator.RequestTrnNpqCheck(JourneyInstance!.InstanceId)); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ingRecordSystem/src/TeachingRecordSystem.AuthorizeAccess/Pages/RequestTrn/NpqCheck.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,25 @@ | ||
@page "/request-trn/npq-check" | ||
@model TeachingRecordSystem.AuthorizeAccess.Pages.RequestTrn.NpqCheckModel | ||
@{ | ||
ViewBag.Title = Html.DisplayNameFor(m => m.IsPlanningToTakeAnNpq); | ||
} | ||
|
||
@section BeforeContent { | ||
<govuk-back-link href="@LinkGenerator.RequestTrn(Model.JourneyInstance!.InstanceId)" /> | ||
} | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds-from-desktop"> | ||
<form action="@LinkGenerator.RequestTrnNpqCheck(Model.JourneyInstance!.InstanceId)" method="post"> | ||
<govuk-radios asp-for="IsPlanningToTakeAnNpq"> | ||
<govuk-radios-fieldset> | ||
<govuk-radios-fieldset-legend is-page-heading="true" class="govuk-fieldset__legend--l" /> | ||
<govuk-radios-item value="@true">Yes</govuk-radios-item> | ||
<govuk-radios-item value="@false">No</govuk-radios-item> | ||
</govuk-radios-fieldset> | ||
</govuk-radios> | ||
|
||
<govuk-button type="submit">Continue</govuk-button> | ||
</form> | ||
</div> | ||
</div> |
44 changes: 44 additions & 0 deletions
44
...RecordSystem/src/TeachingRecordSystem.AuthorizeAccess/Pages/RequestTrn/NpqCheck.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,44 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.Filters; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using TeachingRecordSystem.UiCommon.FormFlow; | ||
|
||
namespace TeachingRecordSystem.AuthorizeAccess.Pages.RequestTrn; | ||
|
||
[Journey(RequestTrnJourneyState.JourneyName), RequireJourneyInstance] | ||
public class NpqCheckModel(AuthorizeAccessLinkGenerator linkGenerator) : PageModel | ||
{ | ||
public JourneyInstance<RequestTrnJourneyState>? JourneyInstance { get; set; } | ||
|
||
[BindProperty] | ||
[Display(Name = "Do you plan on taking a national professional qualification (NPQ)?")] | ||
[Required(ErrorMessage = "Tell us whether you plan on taking a national professional qualification (NPQ)")] | ||
public bool? IsPlanningToTakeAnNpq { get; set; } | ||
|
||
public async Task<IActionResult> OnPost() | ||
{ | ||
if (!ModelState.IsValid) | ||
{ | ||
return this.PageWithErrors(); | ||
} | ||
|
||
await JourneyInstance!.UpdateStateAsync(state => state.IsPlanningToTakeAnNpq = IsPlanningToTakeAnNpq); | ||
|
||
return IsPlanningToTakeAnNpq == true ? | ||
Redirect(linkGenerator.RequestTrnEmail(JourneyInstance!.InstanceId)) : | ||
Redirect(linkGenerator.RequestTrnNotEligible(JourneyInstance.InstanceId)); | ||
} | ||
|
||
public override void OnPageHandlerExecuting(PageHandlerExecutingContext context) | ||
{ | ||
var state = JourneyInstance!.State; | ||
if (state.HasPendingTrnRequest) | ||
{ | ||
context.Result = Redirect(linkGenerator.RequestTrnSubmitted(JourneyInstance!.InstanceId)); | ||
return; | ||
} | ||
|
||
IsPlanningToTakeAnNpq ??= JourneyInstance!.State.IsPlanningToTakeAnNpq; | ||
} | ||
} |
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
Oops, something went wrong.