Skip to content

Commit 9c41649

Browse files
committed
TD-4180: Moved client side validations to server side.
1 parent d728a62 commit 9c41649

13 files changed

+38
-19
lines changed

LearningHub.Nhs.WebUI/Controllers/AccountController.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ public async Task<IActionResult> CreateAccountRegionSelection(AccountCreationVie
476476

477477
if (accountCreation.CountryId == "1")
478478
{
479+
await this.multiPageFormService.SetMultiPageFormData(accountCreation, MultiPageFormDataFeature.AddRegistrationPrompt, this.TempData);
479480
var regionData = await this.regionService.GetAllPagedAsync(accountCreationViewModel.CurrentPageIndex, UserRegistrationContentPageSize);
480481
return this.View(new AccountCreationListViewModel { Region = regionData.Item2, AccountCreationPaging = new AccountCreationPagingModel { TotalItems = regionData.Item1, PageSize = UserRegistrationContentPageSize, HasItems = regionData.Item1 > 0, CurrentPage = accountCreationViewModel.CurrentPageIndex }, RegionId = accountCreation.RegionId, ReturnToConfirmation = accountCreationViewModel.ReturnToConfirmation });
481482
}
@@ -537,7 +538,7 @@ public async Task<IActionResult> CreateAccountSubmitRegionSelection(AccountCreat
537538

538539
if (string.IsNullOrWhiteSpace(accountCreationViewModel.RegionId))
539540
{
540-
if (accountCreation.CountryId == "1")
541+
if (accountCreation.CountryId == "1" || accountCreation.CountryId == null)
541542
{
542543
this.ModelState.AddModelError("RegionId", CommonValidationErrorMessages.RegionRequired);
543544
var region = await this.regionService.GetAllPagedAsync(1, UserRegistrationContentPageSize);
@@ -748,7 +749,7 @@ public async Task<IActionResult> CreateAccountPrimarySpecialty(AccountCreationVi
748749
if (string.IsNullOrWhiteSpace(accountCreationViewModel.GradeId) || !gradeCheck)
749750
{
750751
int gradePageSize = UserRegistrationContentPageSize + 5;
751-
this.ModelState.AddModelError(string.Empty, CommonValidationErrorMessages.GradeRequired);
752+
this.ModelState.AddModelError("GradeId", CommonValidationErrorMessages.GradeRequired);
752753
var gradeLevel = await this.gradeService.GetPagedGradesForJobRoleAsync(int.Parse(accountCreation.CurrentRole), 1, gradePageSize);
753754
return this.View("CreateAccountGradeSelection", new AccountCreationListViewModel { GradeList = gradeLevel.Item2, AccountCreationPaging = new AccountCreationPagingModel { TotalItems = gradeLevel.Item1, PageSize = gradePageSize, HasItems = gradeLevel.Item1 > 0, CurrentPage = 1 }, ReturnToConfirmation = accountCreationViewModel.ReturnToConfirmation });
754755
}

LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.4.1" />
129129
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.10" />
130130
<PackageReference Include="MK.IO" Version="1.5.0" />
131-
<PackageReference Include="NHSUKViewComponents.Web" Version="1.0.25" />
131+
<PackageReference Include="NHSUKViewComponents.Web" Version="1.0.26" />
132132
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
133133
<PrivateAssets>all</PrivateAssets>
134134
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

LearningHub.Nhs.WebUI/Views/Account/CreateAccountCountrySelection.cshtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
@{
55
ViewData["Title"] = "Select Country";
6+
ViewData["DisableValidation"] = true;
67
var errorHasOccurred = !ViewData.ModelState.IsValid;
78
bool returnToConfirmation = false;
89
if (!string.IsNullOrWhiteSpace(Context.Request.Query["returnToConfirmation"]))
@@ -25,7 +26,7 @@
2526

2627
@if (errorHasOccurred)
2728
{
28-
<vc:error-summary order-of-property-names="@(new[] { nameof(Model.FilterText) })" />
29+
<vc:error-summary order-of-property-names="@(new[] { nameof(Model.FilterText), nameof(Model.CountryId) })" />
2930
}
3031
<h1 class="nhsuk-heading-xl">Search results for @Model.FilterText</h1>
3132
<form asp-controller="Account" asp-action="CreateAccountCountrySelection" method="get">

LearningHub.Nhs.WebUI/Views/Account/CreateAccountCurrentRole.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
@{
55
ViewData["Title"] = "Current Role";
6+
ViewData["DisableValidation"] = true;
67
var errorHasOccurred = !ViewData.ModelState.IsValid;
78
bool returnToConfirmation = false;
89
if (!string.IsNullOrWhiteSpace(Context.Request.Query["returnToConfirmation"]))

LearningHub.Nhs.WebUI/Views/Account/CreateAccountEmailVerification.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
@{
99
ViewData["Title"] = "Email Verification";
10+
ViewData["DisableValidation"] = true;
1011
var errorHasOccurred = !ViewData.ModelState.IsValid;
1112
bool returnToConfirmation = false;
1213
if (!string.IsNullOrWhiteSpace(Context.Request.Query["returnToConfirmation"]))

LearningHub.Nhs.WebUI/Views/Account/CreateAccountGradeSelection.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
@{
55
ViewData["Title"] = "Select Grade";
6+
ViewData["DisableValidation"] = true;
67
string currentRole = !string.IsNullOrWhiteSpace(Context.Request.Query["CurrentRole"]) ? Context.Request.Query["CurrentRole"] : Model.CurrentRole;
78
var routeData = new Dictionary<string, string> { { "CurrentRole", currentRole }, { "ReturnToConfirmation", Context.Request.Query["returnToConfirmation"] } };
89
var errorHasOccurred = !ViewData.ModelState.IsValid;

LearningHub.Nhs.WebUI/Views/Account/CreateAccountPersonalDetails.cshtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
@{
88
ViewData["Title"] = "Personal details";
9+
ViewData["DisableValidation"] = true;
910
string email = ViewBag.ValidatedEmail;
1011
var errorHasOccurred = !ViewData.ModelState.IsValid;
1112
AccountCreationTypeEnum accountCreationType = ViewBag.AccountCreationType;
@@ -49,7 +50,7 @@
4950
<input type="hidden" name="formSubmission" value="true">
5051
@if (errorHasOccurred)
5152
{
52-
<vc:error-summary order-of-property-names="@(new[] { nameof(Model) })" />
53+
<vc:error-summary order-of-property-names="@(new[] { nameof(Model.FirstName),nameof(Model.LastName) })" />
5354
}
5455

5556
<vc:text-input asp-for="FirstName"

LearningHub.Nhs.WebUI/Views/Account/CreateAccountPrimarySpecialtySelection.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
@{
66
ViewData["Title"] = "Primary Specialty";
7+
ViewData["DisableValidation"] = true;
78
var errorHasOccurred = !ViewData.ModelState.IsValid;
89
string grade = !string.IsNullOrWhiteSpace(Context.Request.Query["gradeId"]) ? Context.Request.Query["gradeId"] : Model.GradeId;
910
string regNo = !string.IsNullOrWhiteSpace(Context.Request.Query["registrationNumber"]) ? Context.Request.Query["registrationNumber"] : Model.RegistrationNumber;

LearningHub.Nhs.WebUI/Views/Account/CreateAccountRegionSelection.cshtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
@{
55
ViewData["Title"] = "Region";
6+
ViewData["DisableValidation"] = true;
67
var errorHasOccurred = !ViewData.ModelState.IsValid;
78
var routeData = new Dictionary<string, string> { { "ReturnToConfirmation", Context.Request.Query["returnToConfirmation"] } };
89
}
@@ -16,7 +17,7 @@
1617
<vc:back-link asp-controller="Account" asp-action="CreateAccountCountrySelection" asp-all-route-data="@routeData" link-text="Back to: Search for your country" />
1718
@if (errorHasOccurred)
1819
{
19-
<vc:error-summary order-of-property-names="@(new[] { nameof(Model) })" />
20+
<vc:error-summary order-of-property-names="@(new[] { nameof(Model.RegionId) })" />
2021
}
2122
<form asp-controller="Account" asp-action="CreateAccountSubmitRegionSelection" method="post">
2223
<input type="hidden" name="formSubmission" value="true">

LearningHub.Nhs.WebUI/Views/Account/CreateAccountWorkPlace.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
@{
66
ViewData["Title"] = "Work Place";
7+
ViewData["DisableValidation"] = true;
78
var errorHasOccurred = !ViewData.ModelState.IsValid;
89
TextInfo textInfo = CultureInfo.CurrentCulture.TextInfo;
910
bool returnToConfirmation = false;

0 commit comments

Comments
 (0)