Skip to content

Commit f243509

Browse files
committed
TD-5402 - Updated model with validation context for invalid ModelState
1 parent 3b0c250 commit f243509

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

DigitalLearningSolutions.Web/Controllers/CompetencyAssessmentsController/CompetencyAssessments.cs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -712,11 +712,11 @@ public IActionResult CompetencyAssessmentSummary(CompetencyAssessmentFeaturesVie
712712
[Route("/CompetencyAssessments/{competencyAssessmentId}/Frameworks/{frameworkId}/Make")]
713713
public IActionResult ConfirmMaKePrimaryFramework(int frameworkId, int competencyAssessmentId)
714714
{
715-
var adminId = GetAdminID();
716-
var competencyAssessmentBase = competencyAssessmentService.GetCompetencyAssessmentBaseById(competencyAssessmentId, adminId);
717-
var framework = frameworkService.GetFrameworkDetailByFrameworkId(frameworkId, adminId);
718-
var model = new ConfirmMakePrimaryFrameworkViewModel(competencyAssessmentBase, framework);
719-
return View("ConfirmMaKePrimaryFramework", model);
715+
var adminId = GetAdminID();
716+
var competencyAssessmentBase = competencyAssessmentService.GetCompetencyAssessmentBaseById(competencyAssessmentId, adminId);
717+
var framework = frameworkService.GetFrameworkDetailByFrameworkId(frameworkId, adminId);
718+
var model = new ConfirmMakePrimaryFrameworkViewModel(competencyAssessmentBase, framework);
719+
return View("ConfirmMaKePrimaryFramework", model);
720720
}
721721
[HttpPost]
722722
[Route("/CompetencyAssessments/{competencyAssessmentId}/Frameworks/{frameworkId}/Make")]
@@ -897,7 +897,6 @@ public IActionResult OptionsLabels(OptionsLabelsViewModel model)
897897
}
898898
else if (model.CurrentStep == (int)OptionLabel.QuestionLabels)
899899
{
900-
data.QuestionLabel = model.QuestionLabel;
901900
if (model.QuestionLabel)
902901
{
903902
var label = model.QuestionLabelText?.Trim();
@@ -908,17 +907,18 @@ public IActionResult OptionsLabels(OptionsLabelsViewModel model)
908907

909908
if (!ModelState.IsValid)
910909
{
911-
SetOptionsLabelsData(data);
912-
model = new OptionsLabelsViewModel(data);
910+
var errModel = new OptionsLabelsViewModel(data);
911+
errModel.QuestionLabel = model.QuestionLabel;
912+
errModel.QuestionLabelText = model.QuestionLabelText;
913913
model.Error = true;
914-
return View("CompetencyAssessmentOptions", model);
914+
return View("CompetencyAssessmentOptions", errModel);
915915
}
916916
}
917+
data.QuestionLabel = model.QuestionLabel;
917918
data.QuestionLabelText = model.QuestionLabel ? model.QuestionLabelText.Trim() : null;
918919
}
919920
else if (model.CurrentStep == (int)OptionLabel.CommentsLabel)
920921
{
921-
data.ReviewerCommentsLabel = model.ReviewerCommentsLabel;
922922
if (model.ReviewerCommentsLabel)
923923
{
924924
var label = model.ReviewerCommentsLabelText?.Trim();
@@ -929,12 +929,14 @@ public IActionResult OptionsLabels(OptionsLabelsViewModel model)
929929

930930
if (!ModelState.IsValid)
931931
{
932-
SetOptionsLabelsData(data);
933-
model = new OptionsLabelsViewModel(data);
934-
model.Error = true;
935-
return View("CompetencyAssessmentOptions", model);
932+
var errModel = new OptionsLabelsViewModel(data);
933+
errModel.ReviewerCommentsLabel = model.ReviewerCommentsLabel;
934+
errModel.ReviewerCommentsLabelText = model.ReviewerCommentsLabelText;
935+
errModel.Error = true;
936+
return View("CompetencyAssessmentOptions", errModel);
936937
}
937938
}
939+
data.ReviewerCommentsLabel = model.ReviewerCommentsLabel;
938940
data.ReviewerCommentsLabelText = model.ReviewerCommentsLabel ? model.ReviewerCommentsLabelText.Trim() : null;
939941
}
940942
else if (model.CurrentStep == (int)OptionLabel.Summary)

DigitalLearningSolutions.Web/Views/CompetencyAssessments/CompetencyAssessmentOptions.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
</h1>
135135
</legend>
136136
<div id="example-hints-hint" class="nhsuk-hint">
137-
Do you want the learner to work through competencies using next and previous links? If not, the learner will navigate between @Model.VocabularyPlural.ToLower() using the @Model.VocabularySingular.ToLower() menu.
137+
Do you want the learner to work through @Model.VocabularyPlural.ToLower() using next and previous links? If not, the learner will navigate between @Model.VocabularyPlural.ToLower() using the @Model.VocabularySingular.ToLower() menu.
138138
</div>
139139
<div class="nhsuk-radios" id="LinearNavigation">
140140
<div class="nhsuk-radios__item">

0 commit comments

Comments
 (0)