This commit is contained in:
2025-12-25 13:54:49 -06:00
parent d405b61ddd
commit 3457721238
26 changed files with 3509 additions and 139 deletions

View File

@@ -51,5 +51,57 @@ namespace MieSystem.Models
[Column("activo")]
public bool Activo { get; set; }
// Propiedades calculadas (solo lectura)
public string NombreCompleto => $"{Nombre} {Apellidos}".Trim();
public int Edad
{
get
{
var today = DateTime.Today;
var age = today.Year - FechaNacimiento.Year;
// Si aún no ha cumplido años este año, restar 1
if (FechaNacimiento.Date > today.AddYears(-age))
{
age--;
}
return age;
}
}
// Otra propiedad útil para mostrar
public string EdadConMeses
{
get
{
var today = DateTime.Today;
var age = today.Year - FechaNacimiento.Year;
var months = today.Month - FechaNacimiento.Month;
if (today.Day < FechaNacimiento.Day)
{
months--;
}
if (months < 0)
{
age--;
months += 12;
}
return $"{age} años, {months} meses";
}
}
// Para mostrar en selectores
public string NombreConEdad => $"{NombreCompleto} ({Edad} años)";
// Para mostrar en listas
public string InformacionBasica => $"{NombreCompleto} | {Edad} años | {Sexo}";
}
}