-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRadiosViewModel.cs
More file actions
44 lines (39 loc) · 1.43 KB
/
RadiosViewModel.cs
File metadata and controls
44 lines (39 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
namespace NHSUKViewComponents.Web.ViewModels
{
using System.Collections.Generic;
using System.Linq;
public class RadiosViewModel
{
public RadiosViewModel(
string aspFor,
string label,
string hintText,
IEnumerable<RadiosItemViewModel> radios,
IEnumerable<string> errorMessages,
bool required,
string? requiredClientSideErrorMessage = default,
string? cssClass = default
)
{
var errorMessageList = errorMessages.ToList();
AspFor = aspFor;
Label = !required && !label.EndsWith("(optional)") ? label + " (optional)" : label;
HintText = hintText;
Radios = radios;
ErrorMessages = errorMessageList;
HasError = errorMessageList.Any();
Required = required;
RequiredClientSideErrorMessage = requiredClientSideErrorMessage;
Class = cssClass;
}
public string AspFor { get; set; }
public string Label { get; set; }
public string HintText { get; set; }
public string? Class { get; set; }
public IEnumerable<string> ErrorMessages { get; set; }
public readonly bool HasError;
public IEnumerable<RadiosItemViewModel> Radios { get; set; }
public bool Required { get; set; }
public string RequiredClientSideErrorMessage { get; set; }
}
}