147 lines
4.6 KiB
C#
147 lines
4.6 KiB
C#
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<string>();
|
|
|
|
}
|
|
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? VendorId { get; set; }
|
|
public string Wiki { get; set; }
|
|
public string CustomFields { get; set; }
|
|
public List<string> Tags { get; set; }
|
|
|
|
public DateTime? LastLogin { get; set; }
|
|
|
|
[NotMapped, JsonIgnore]
|
|
public AyaType AyaType { get => AyaType.User; }
|
|
|
|
public bool IsOutsideUser
|
|
{
|
|
get
|
|
{
|
|
return this.UserType == UserType.Customer || this.UserType == UserType.HeadOffice;
|
|
}
|
|
}
|
|
|
|
// [JsonIgnore]//hide from being returned (as null anyway) with User object in routes
|
|
// public UserOptions UserOptions { get; set; }
|
|
}//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; }
|
|
public bool TwoFactorEnabled {get;set;}
|
|
[Required]
|
|
public AuthorizationRoles Roles { get; set; }
|
|
[Required]
|
|
public UserType UserType { get; set; }
|
|
[NotMapped]
|
|
public string UserTypeViz { get; set; }
|
|
[MaxLength(255)]
|
|
public string EmployeeNumber { get; set; }
|
|
public string Notes { get; set; }
|
|
public long? CustomerId { get; set; }
|
|
[NotMapped]
|
|
public string CustomerViz { get; set; }
|
|
public long? HeadOfficeId { get; set; }
|
|
[NotMapped]
|
|
public string HeadOfficeViz { get; set; }
|
|
public long? VendorId { get; set; }
|
|
[NotMapped]
|
|
public string VendorViz { get; set; }
|
|
public string Wiki { get; set; }
|
|
public string CustomFields { get; set; }
|
|
public List<string> Tags { get; set; }
|
|
|
|
//======================
|
|
//NOT IN DTUSER CLASS
|
|
[JsonIgnore]
|
|
public string Salt { get; set; }//---
|
|
[JsonIgnore]
|
|
public string CurrentAuthToken { get; set; }//---
|
|
[JsonIgnore]
|
|
public string DlKey { get; set; }//---
|
|
[JsonIgnore]
|
|
public DateTime? DlKeyExpire { get; set; }//---
|
|
[JsonIgnore]
|
|
public string PasswordResetCode { get; set; }//---
|
|
[JsonIgnore]
|
|
public DateTime? PasswordResetCodeExpire { get; set; }//---
|
|
[JsonIgnore]
|
|
public string HotpSecret { 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]
|
|
public Customer Customer { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public HeadOffice HeadOffice { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public Vendor Vendor { 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<string>();
|
|
|
|
}
|
|
|
|
public bool IsTech
|
|
{
|
|
get
|
|
{
|
|
return this.UserType == UserType.ServiceContractor || this.UserType == UserType.Service;
|
|
}
|
|
}
|
|
|
|
public bool IsOutsideUser
|
|
{
|
|
get
|
|
{
|
|
return this.UserType == UserType.Customer || this.UserType == UserType.HeadOffice;
|
|
}
|
|
}
|
|
|
|
|
|
[NotMapped, JsonIgnore]
|
|
public AyaType AyaType { get => AyaType.User; }
|
|
|
|
}//eoc
|
|
} |