back photo + event tags and persons
This commit is contained in:
38
back/DataModels/UserModel.cs
Normal file
38
back/DataModels/UserModel.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace back.DataModels;
|
||||
|
||||
[Table("Users")]
|
||||
public class UserModel : PersonModel
|
||||
{
|
||||
[Required]
|
||||
public string Email { get; set; }
|
||||
[Required, MinLength(8)]
|
||||
public string Password { get; set; }
|
||||
public List<RoleModel> Role { get; set; }
|
||||
|
||||
public UserModel(string id, string email, string password, string name, List<RoleModel> role, DateTime createdAt, DateTime updatedAt)
|
||||
: base(id, name)
|
||||
{
|
||||
Email = email;
|
||||
Password = password;
|
||||
Role = role;
|
||||
CreatedAt = createdAt;
|
||||
UpdatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public bool IsAdmin => Role.Exists(r => r.IsAdmin);
|
||||
public bool IsContentManager => Role.Exists(r => r.IsContentManager);
|
||||
public bool IsUser => Role.Exists(r => r.IsUser);
|
||||
|
||||
public static readonly UserModel DefaultUser = new(
|
||||
"0",
|
||||
"default@example.com",
|
||||
string.Empty,
|
||||
"Default User",
|
||||
[RoleModel.UserRole],
|
||||
DateTime.UtcNow,
|
||||
DateTime.UtcNow
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user