108 lines
2.9 KiB
C#
108 lines
2.9 KiB
C#
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace MieSystem.Models
|
|
{
|
|
public class Expediente
|
|
{
|
|
[Column("id")]
|
|
public int Id { get; set; }
|
|
|
|
[Column("nombre")]
|
|
public string Nombre { get; set; }
|
|
|
|
[Column("apellidos")]
|
|
public string Apellidos { get; set; }
|
|
|
|
[Column("fecha_nacimiento")]
|
|
public DateTime FechaNacimiento { get; set; }
|
|
|
|
[Column("nombre_padre")]
|
|
public string NombrePadre { get; set; }
|
|
|
|
[Column("nombre_madre")]
|
|
public string NombreMadre { get; set; }
|
|
|
|
[Column("nombre_responsable")]
|
|
public string NombreResponsable { get; set; }
|
|
|
|
[Column("parentesco_responsable")]
|
|
public string ParentescoResponsable { get; set; }
|
|
|
|
[Column("sexo")]
|
|
public string Sexo { get; set; }
|
|
|
|
[Column("direccion")]
|
|
public string Direccion { get; set; }
|
|
|
|
[Column("telefono")]
|
|
public string Telefono { get; set; }
|
|
|
|
[Column("observaciones")]
|
|
public string Observaciones { get; set; }
|
|
|
|
[Column("foto_url")]
|
|
public string FotoUrl { get; set; }
|
|
|
|
[Column("fecha_creacion")]
|
|
public DateTime FechaCreacion { get; set; }
|
|
|
|
[Column("fecha_actualizacion")]
|
|
public DateTime FechaActualizacion { get; set; }
|
|
|
|
[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}";
|
|
}
|
|
}
|