-
Notifications
You must be signed in to change notification settings - Fork 11
/
Admin.cs
63 lines (50 loc) · 1.65 KB
/
Admin.cs
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
namespace Prime.Models
{
[Table("Admin")]
public class Admin : BaseAuditable, IValidatableObject, IUserBoundModel
{
[Key]
public int Id { get; set; }
public Guid UserId { get; set; }
[Required]
public string FirstName { get; set; }
[Required]
public string LastName { get; set; }
[Required]
public string Email { get; set; }
[Required]
public string IDIR { get; set; }
[Required]
[DefaultValue(AdminStatusType.Enabled)]
public AdminStatusType Status { get; set; }
/// <summary>
/// e.g. "jsmith@idir"
/// </summary>
public string Username { get; set; }
[JsonIgnore]
public IEnumerable<Enrollee> Enrollees { get; set; }
[JsonIgnore]
public IEnumerable<Site> Sites { get; set; }
[JsonIgnore]
public IEnumerable<EnrolleeNote> AdjudicatorNotes { get; set; }
[JsonIgnore]
public IEnumerable<EnrolmentStatusReference> EnrolmentStatusReference { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (Guid.Empty.Equals(UserId))
{
yield return new ValidationResult($"UserId cannot be empty");
}
if (null == Username)
{
yield return new ValidationResult($"Username cannot be empty");
}
}
}
}