2026-04-13 21:36:00 -03:00
|
|
|
namespace SIGCM2.Domain.Entities;
|
|
|
|
|
|
|
|
|
|
public sealed class Usuario
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; }
|
|
|
|
|
public string Username { get; }
|
|
|
|
|
public string PasswordHash { get; }
|
|
|
|
|
public string Nombre { get; }
|
|
|
|
|
public string Apellido { get; }
|
|
|
|
|
public string? Email { get; }
|
|
|
|
|
public string Rol { get; }
|
|
|
|
|
public string PermisosJson { get; }
|
|
|
|
|
public bool Activo { get; }
|
|
|
|
|
|
|
|
|
|
public Usuario(
|
|
|
|
|
int id,
|
|
|
|
|
string username,
|
|
|
|
|
string passwordHash,
|
|
|
|
|
string nombre,
|
|
|
|
|
string apellido,
|
|
|
|
|
string? email,
|
|
|
|
|
string rol,
|
|
|
|
|
string permisosJson,
|
|
|
|
|
bool activo)
|
|
|
|
|
{
|
|
|
|
|
Id = id;
|
|
|
|
|
Username = username;
|
|
|
|
|
PasswordHash = passwordHash;
|
|
|
|
|
Nombre = nombre;
|
|
|
|
|
Apellido = apellido;
|
|
|
|
|
Email = email;
|
|
|
|
|
Rol = rol;
|
|
|
|
|
PermisosJson = permisosJson;
|
|
|
|
|
Activo = activo;
|
|
|
|
|
}
|
2026-04-15 10:47:48 -03:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Factory for creating a new user (no Id — DB assigns via IDENTITY).
|
|
|
|
|
/// Defaults: Activo=true, PermisosJson="[]".
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static Usuario ForCreation(
|
|
|
|
|
string username,
|
|
|
|
|
string passwordHash,
|
|
|
|
|
string nombre,
|
|
|
|
|
string apellido,
|
|
|
|
|
string? email,
|
|
|
|
|
string rol)
|
|
|
|
|
{
|
|
|
|
|
return new Usuario(
|
|
|
|
|
id: 0,
|
|
|
|
|
username: username,
|
|
|
|
|
passwordHash: passwordHash,
|
|
|
|
|
nombre: nombre,
|
|
|
|
|
apellido: apellido,
|
|
|
|
|
email: email,
|
|
|
|
|
rol: rol,
|
|
|
|
|
permisosJson: "[]",
|
|
|
|
|
activo: true);
|
|
|
|
|
}
|
2026-04-13 21:36:00 -03:00
|
|
|
}
|