Nueva mejoras Y estabilidad
This commit is contained in:
@@ -1,33 +1,64 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace MieSystem.Models
|
||||
{
|
||||
[Table("asistencia", Schema = "public")]
|
||||
public class Asistencia
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("id")]
|
||||
public int Id { get; set; }
|
||||
public int ExpedienteId { get; set; }
|
||||
public DateTime Fecha { get; set; }
|
||||
public string Estado { get; set; } // P, T, F
|
||||
public TimeSpan? HoraEntrada { get; set; }
|
||||
public TimeSpan? HoraSalida { get; set; }
|
||||
public string Observaciones { get; set; }
|
||||
public DateTime FechaRegistro { get; set; }
|
||||
public string UsuarioRegistro { get; set; }
|
||||
|
||||
// Propiedades calculadas
|
||||
[Required]
|
||||
[Column("expediente_id")]
|
||||
public int ExpedienteId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("fecha")]
|
||||
public DateTime Fecha { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("estado")]
|
||||
public char Estado { get; set; } // P, T, F
|
||||
|
||||
[Column("hora_entrada")]
|
||||
public TimeSpan? HoraEntrada { get; set; }
|
||||
|
||||
[Column("hora_salida")]
|
||||
public TimeSpan? HoraSalida { get; set; }
|
||||
|
||||
[Column("observaciones")]
|
||||
public string? Observaciones { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("fecha_registro")]
|
||||
public DateTime FechaRegistro { get; set; }
|
||||
|
||||
[StringLength(100)]
|
||||
[Column("usuario_registro")]
|
||||
public string? UsuarioRegistro { get; set; }
|
||||
|
||||
// ==========================
|
||||
// PROPIEDADES CALCULADAS
|
||||
// ==========================
|
||||
|
||||
[NotMapped]
|
||||
public string EstadoTexto => Estado switch
|
||||
{
|
||||
"P" => "Presente",
|
||||
"T" => "Tarde",
|
||||
"F" => "Falto",
|
||||
'P' => "Presente",
|
||||
'T' => "Tarde",
|
||||
'F' => "Faltó",
|
||||
_ => "Desconocido"
|
||||
};
|
||||
|
||||
[NotMapped]
|
||||
public string ColorEstado => Estado switch
|
||||
{
|
||||
"P" => "success",
|
||||
"T" => "warning",
|
||||
"F" => "danger",
|
||||
'P' => "success",
|
||||
'T' => "warning",
|
||||
'F' => "danger",
|
||||
_ => "secondary"
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,62 +1,85 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace MieSystem.Models
|
||||
{
|
||||
[Table("expedientes")]
|
||||
public class Expediente
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
|
||||
[Required]
|
||||
[StringLength(100)]
|
||||
[Column("nombre")]
|
||||
public string Nombre { get; set; }
|
||||
|
||||
public string Nombre { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[StringLength(150)]
|
||||
[Column("apellidos")]
|
||||
public string Apellidos { get; set; }
|
||||
|
||||
public string Apellidos { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[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; }
|
||||
|
||||
|
||||
[Required]
|
||||
[StringLength(1)]
|
||||
[Column("sexo")]
|
||||
public string Sexo { get; set; }
|
||||
|
||||
public string Sexo { get; set; } = string.Empty;
|
||||
|
||||
[StringLength(150)]
|
||||
[Column("nombre_padre")]
|
||||
public string? NombrePadre { get; set; }
|
||||
|
||||
[StringLength(150)]
|
||||
[Column("nombre_madre")]
|
||||
public string? NombreMadre { get; set; }
|
||||
|
||||
[StringLength(150)]
|
||||
[Column("nombre_responsable")]
|
||||
public string? NombreResponsable { get; set; }
|
||||
|
||||
[StringLength(50)]
|
||||
[Column("parentesco_responsable")]
|
||||
public string? ParentescoResponsable { get; set; }
|
||||
|
||||
[Column("direccion")]
|
||||
public string Direccion { get; set; }
|
||||
|
||||
public string? Direccion { get; set; }
|
||||
|
||||
[StringLength(20)]
|
||||
[Column("telefono")]
|
||||
public string Telefono { get; set; }
|
||||
|
||||
public string? Telefono { get; set; }
|
||||
|
||||
[Column("observaciones")]
|
||||
public string Observaciones { get; set; }
|
||||
|
||||
public string? Observaciones { get; set; }
|
||||
|
||||
[StringLength(500)]
|
||||
[Column("foto_url")]
|
||||
public string FotoUrl { get; set; }
|
||||
|
||||
public string? FotoUrl { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("fecha_creacion")]
|
||||
public DateTime FechaCreacion { get; set; }
|
||||
|
||||
|
||||
[Required]
|
||||
[Column("fecha_actualizacion")]
|
||||
public DateTime FechaActualizacion { get; set; }
|
||||
|
||||
|
||||
[Required]
|
||||
[Column("activo")]
|
||||
public bool Activo { get; set; }
|
||||
|
||||
// ============================
|
||||
// 🔹 Propiedades calculadas
|
||||
// ============================
|
||||
|
||||
|
||||
// Propiedades calculadas (solo lectura)
|
||||
[NotMapped]
|
||||
public string NombreCompleto => $"{Nombre} {Apellidos}".Trim();
|
||||
|
||||
[NotMapped]
|
||||
public int Edad
|
||||
{
|
||||
get
|
||||
@@ -64,17 +87,14 @@ namespace MieSystem.Models
|
||||
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
|
||||
[NotMapped]
|
||||
public string EdadConMeses
|
||||
{
|
||||
get
|
||||
@@ -84,9 +104,7 @@ namespace MieSystem.Models
|
||||
var months = today.Month - FechaNacimiento.Month;
|
||||
|
||||
if (today.Day < FechaNacimiento.Day)
|
||||
{
|
||||
months--;
|
||||
}
|
||||
|
||||
if (months < 0)
|
||||
{
|
||||
@@ -98,10 +116,10 @@ namespace MieSystem.Models
|
||||
}
|
||||
}
|
||||
|
||||
// Para mostrar en selectores
|
||||
[NotMapped]
|
||||
public string NombreConEdad => $"{NombreCompleto} ({Edad} años)";
|
||||
|
||||
// Para mostrar en listas
|
||||
[NotMapped]
|
||||
public string InformacionBasica => $"{NombreCompleto} | {Edad} años | {Sexo}";
|
||||
}
|
||||
}
|
||||
|
||||
43
MieSystem/Models/Persona.cs
Normal file
43
MieSystem/Models/Persona.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace MieSystem.Models;
|
||||
|
||||
[Table("Personas", Schema = "public")]
|
||||
public class Persona
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("Id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(250)]
|
||||
[Column("Nombres")]
|
||||
public string Nombres { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[StringLength(250)]
|
||||
[Column("Apellidos")]
|
||||
public string Apellidos { get; set; } = string.Empty;
|
||||
|
||||
[StringLength(50)]
|
||||
[Column("DUI")]
|
||||
public string? Dui { get; set; }
|
||||
|
||||
[StringLength(1000)]
|
||||
[Column("Direccion")]
|
||||
public string? Direccion { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("sexo")]
|
||||
public char Sexo { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("FechaNacimiento")]
|
||||
public DateTime FechaNacimiento { get; set; }
|
||||
|
||||
[StringLength(1000)]
|
||||
[Column("FotoUrl")]
|
||||
public string? FotoUrl { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user