Files
mmorales.photo/back/DataModels/UserModel.cs

39 lines
1.1 KiB
C#

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
);
}