using System; using System.Collections.Generic; using AyaNova.Biz; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Newtonsoft.Json; namespace AyaNova.Models { public class dtUser : ICoreBizObjectModel//used to return user object without auth related fields in UserGet route { public dtUser() { Tags = new List(); } public long Id { get; set; } public uint Concurrency { get; set; } public bool Active { get; set; } [Required, MaxLength(255)] public string Name { get; set; } public AuthorizationRoles Roles { get; set; } public UserType UserType { get; set; } public string EmployeeNumber { get; set; } public string Notes { get; set; } public long? CustomerId { get; set; } public long? HeadOfficeId { get; set; } public long? SubVendorId { get; set; } public string Wiki { get; set; } public string CustomFields { get; set; } public List Tags { get; set; } public DateTime? LastLogin { get; set; } [NotMapped, JsonIgnore] public AyaType AyaType { get => AyaType.User; } }//eoc public class User : ICoreBizObjectModel { public long Id { get; set; } public uint Concurrency { get; set; } [Required] public bool Active { get; set; } [Required, MaxLength(255)] public string Name { get; set; } public DateTime? LastLogin { get; set; } public string Login { get; set; } public string Password { get; set; } [JsonIgnore] public string Salt { get; set; } [JsonIgnore] public string CurrentAuthToken { get; set; } [JsonIgnore] public string DlKey { get; set; } [JsonIgnore] public DateTime? DlKeyExpire { get; set; } [Required] public AuthorizationRoles Roles { get; set; } [Required] public UserType UserType { get; set; } [MaxLength(255)] public string EmployeeNumber { get; set; } public string Notes { get; set; } public long? CustomerId { get; set; } public long? HeadOfficeId { get; set; } public long? SubVendorId { get; set; } public string Wiki { get; set; } public string CustomFields { get; set; } public List Tags { get; set; } //relations //https://docs.microsoft.com/en-us/ef/core/modeling/relationships#other-relationship-patterns [JsonIgnore]//hide from being returned (as null anyway) with User object in routes public UserOptions UserOptions { get; set; } [JsonIgnore]//hide from being returned (as null anyway) with User object in routes public Widget Widget { get; set; } public User() { Tags = new List(); } public bool IsTech { get { return this.UserType == UserType.ServiceContractor || this.UserType == UserType.Service; } } [NotMapped, JsonIgnore] public AyaType AyaType { get => AyaType.User; } }//eoc }