Association in user

This commit is contained in:
2019-01-21 15:04:00 +01:00
parent b7460cfd78
commit 062bdff9da
8 changed files with 61 additions and 64 deletions

View File

@@ -1,5 +1,6 @@
using LinqToDB.Mapping;
using Newtonsoft.Json;
using SeniorAssistant.Models.Users;
namespace SeniorAssistant.Models
{
@@ -8,15 +9,27 @@ namespace SeniorAssistant.Models
[Column(IsPrimaryKey = true, CanBeNull = false)]
public string Username { get; set; }
[NotNull]
[Column(CanBeNull = false)]
public string Email { get; set; }
[NotNull]
[JsonIgnore]
[Column(CanBeNull = false)]
public string Password { get; set; }
public string Name { get; set; }
public string LastName { get; set; }
[JsonIgnore]
[Association(ThisKey = nameof(Username), OtherKey = nameof(Doctor.Username), CanBeNull = true)]
public Doctor Doc { get; set; }
[JsonIgnore]
[Association(ThisKey = nameof(Username), OtherKey = nameof(Patient.Username), CanBeNull = true)]
public Patient Pat { get; set; }
public bool IsDoctor() => Doc != null;
public bool IsPatient() => Pat != null;
}
}