Skip to content

Commit 13cefc0

Browse files
committed
TD-5154 Adds always show description validation
1 parent 86add18 commit 13cefc0

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

DigitalLearningSolutions.Data/Models/Frameworks/Import/CompetencyTableRow.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace DigitalLearningSolutions.Data.Models.Frameworks.Import
22
{
33
using ClosedXML.Excel;
4-
using Org.BouncyCastle.Asn1.X509;
54

65
public enum RowStatus
76
{
@@ -12,7 +11,8 @@ public enum RowStatus
1211
CompetencyUpdated,
1312
CompetencyGroupInserted,
1413
CompetencyGroupUpdated,
15-
CompetencyGroupAndCompetencyUpdated
14+
CompetencyGroupAndCompetencyUpdated,
15+
InvalidAlwaysShowDescription
1616
}
1717
public class CompetencyTableRow : BulkCompetency
1818
{
@@ -30,10 +30,13 @@ public CompetencyTableRow(IXLTable table, IXLRangeRow row)
3030
Competency = FindFieldValue("Competency");
3131
CompetencyDescription = FindFieldValue("CompetencyDescription");
3232
GroupDescription = FindFieldValue("GroupDescription");
33+
AlwaysShowDescriptionRaw = FindFieldValue("AlwaysShowDescription");
34+
AlwaysShowDescription = bool.TryParse(AlwaysShowDescriptionRaw, out var hasPrn) ? hasPrn : (bool?)null;
3335
FlagsCsv = FindFieldValue("FlagsCSV");
3436
RowStatus = RowStatus.NotYetProcessed;
3537
}
3638
public int RowNumber { get; set; }
39+
public string? AlwaysShowDescriptionRaw { get; set; }
3740
public ImportCompetenciesResult.ErrorReason? Error { get; set; }
3841
public RowStatus RowStatus { get; set; }
3942
public bool Validate()
@@ -50,6 +53,10 @@ public bool Validate()
5053
{
5154
Error = ImportCompetenciesResult.ErrorReason.TooLongCompetencyName;
5255
}
56+
else if (!string.IsNullOrWhiteSpace(AlwaysShowDescriptionRaw) && !bool.TryParse(AlwaysShowDescriptionRaw, out _))
57+
{
58+
Error = ImportCompetenciesResult.ErrorReason.InvalidAlwaysShowDescription;
59+
}
5360

5461
return !Error.HasValue;
5562
}

DigitalLearningSolutions.Web/ViewModels/Frameworks/ImportCompetenciesPreProcessViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private static string MapReasonToErrorMessage(ImportCompetenciesResult.ErrorReas
4343
ImportCompetenciesResult.ErrorReason.TooLongCompetencyName =>
4444
"Competency must be 255 characters or less.",
4545
ImportCompetenciesResult.ErrorReason.InvalidAlwaysShowDescription =>
46-
"Always show description is invalid. The Always show description field must contain 'TRUE' or 'FALSE'",
46+
"Always show description is invalid. The Always show description field must contain 'TRUE' or 'FALSE'",
4747
_ => "Unspecified error.",
4848
};
4949
}

0 commit comments

Comments
 (0)