Skip to content

Commit

Permalink
Fix selected trn from being lost when merging two records (#780)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKevJoy authored Jan 15, 2024
1 parent 6e6dd21 commit 5d661a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
}

@section BeforeContent {
<govuk-back-link asp-page="SelectUser" asp-route-userId="@Model.UserId"/>
<govuk-back-link asp-page="SelectUser" asp-route-userId="@Model.UserId" />
}

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop">
<form asp-page="Confirm" method="post">
<h1 class="govuk-heading-l">@ViewBag.Title</h1>

@Html.Hidden("ChosenTrn", Model.ChosenTrn)
<govuk-summary-list>
<govuk-summary-list-row>
<govuk-summary-list-row-key>Email address</govuk-summary-list-row-key>
<govuk-summary-list-row-value>@Model.User!.EmailAddress</govuk-summary-list-row-value>
</govuk-summary-list-row>
<govuk-summary-list-row>
<govuk-summary-list-row-key>Name</govuk-summary-list-row-key>
<govuk-summary-list-row-value>@Model.User!.FirstName @Model.User!.LastName</govuk-summary-list-row-value>
<govuk-summary-list-row-value>@Model.User!.FirstName @Model.User!.LastName</govuk-summary-list-row-value>
</govuk-summary-list-row>
<govuk-summary-list-row>
<govuk-summary-list-row-key>TRN</govuk-summary-list-row-key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ public Confirm(TeacherIdentityServerDbContext dbContext, IClock clock)

public User? UserToMerge { get; set; }

[FromQuery(Name = "trn")]
[BindProperty]
public string? ChosenTrn { get; set; }


public void OnGet()
{
}
Expand Down Expand Up @@ -121,6 +122,11 @@ private void UpdateMergedUser(User user)

private bool ValidateChosenTrn()
{
if (Request.Query.ContainsKey("trn"))
{
ChosenTrn = Request.Query["trn"];
}

ChosenTrn = ChosenTrn == "None" ? null : ChosenTrn ?? User!.Trn;
return ChosenTrn == User!.Trn || ChosenTrn == UserToMerge!.Trn;
}
Expand Down

0 comments on commit 5d661a8

Please sign in to comment.