Trabajo de ajuste en widgets y db para frontend

This commit is contained in:
2025-08-29 09:54:22 -03:00
parent 55954e18a7
commit 1ed9a49a53
93 changed files with 10259 additions and 609 deletions

View File

@@ -15,11 +15,17 @@ public class EleccionesDbContext(DbContextOptions<EleccionesDbContext> options)
public DbSet<ResumenVoto> ResumenesVotos { get; set; }
public DbSet<EstadoRecuentoGeneral> EstadosRecuentosGenerales { get; set; }
public DbSet<CategoriaElectoral> CategoriasElectorales { get; set; }
public DbSet<AdminUser> AdminUsers { get; set; }
public DbSet<Configuracion> Configuraciones { get; set; }
public DbSet<Bancada> Bancadas { get; set; }
public DbSet<OcupanteBanca> OcupantesBancas { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.UseCollation("Modern_Spanish_CI_AS");
modelBuilder.Entity<ResultadoVoto>()
.HasIndex(r => new { r.AmbitoGeograficoId, r.CategoriaId, r.AgrupacionPoliticaId })
.IsUnique();
@@ -43,19 +49,31 @@ public class EleccionesDbContext(DbContextOptions<EleccionesDbContext> options)
.Property(e => e.VotosPorcentaje).HasPrecision(5, 2);
modelBuilder.Entity<EstadoRecuentoGeneral>(entity =>
{
// Le decimos a EF que la combinación única es (AmbitoGeograficoId, CategoriaId)
entity.HasKey(e => new { e.AmbitoGeograficoId, e.CategoriaId });
{
// Le decimos a EF que la combinación única es (AmbitoGeograficoId, CategoriaId)
entity.HasKey(e => new { e.AmbitoGeograficoId, e.CategoriaId });
// Mantener la configuración de precisión
entity.Property(e => e.MesasTotalizadasPorcentaje).HasPrecision(5, 2);
entity.Property(e => e.ParticipacionPorcentaje).HasPrecision(5, 2);
});
// Mantener la configuración de precisión
entity.Property(e => e.MesasTotalizadasPorcentaje).HasPrecision(5, 2);
entity.Property(e => e.ParticipacionPorcentaje).HasPrecision(5, 2);
});
modelBuilder.Entity<ProyeccionBanca>(entity =>
{
// La combinación de ámbito, categoría y agrupación debe ser única.
entity.HasIndex(p => new { p.AmbitoGeograficoId, p.CategoriaId, p.AgrupacionPoliticaId })
.IsUnique();
});
modelBuilder.Entity<Bancada>(entity =>
{
// Define la relación uno a uno: una Bancada tiene un Ocupante.
entity.HasOne(b => b.Ocupante)
.WithOne(o => o.Bancada)
.HasForeignKey<OcupanteBanca>(o => o.BancadaId);
});
modelBuilder.Entity<OcupanteBanca>(entity =>
{
// Opcional: puede definir un índice
entity.HasIndex(o => o.BancadaId).IsUnique();
});
}
}