Feat Widgets

- Widget de Home
- Widget Cards por Provincias
- Widget Mapa por Categorias
This commit is contained in:
2025-10-01 10:03:01 -03:00
parent 3b0eee25e6
commit a985cbfd7c
45 changed files with 1786 additions and 953 deletions

View File

@@ -30,6 +30,13 @@ public class EleccionesDbContext(DbContextOptions<EleccionesDbContext> options)
modelBuilder.UseCollation("Modern_Spanish_CI_AS");
modelBuilder.Entity<Eleccion>(entity =>
{
// Le decimos a EF que proporcionaremos el valor de la clave primaria.
// Esto evita que la configure como una columna IDENTITY en SQL Server.
entity.Property(e => e.Id).ValueGeneratedNever();
});
modelBuilder.Entity<ResultadoVoto>()
.HasIndex(r => new { r.AmbitoGeograficoId, r.CategoriaId, r.AgrupacionPoliticaId })
.IsUnique();

View File

@@ -10,8 +10,8 @@ public class LogoAgrupacionCategoria
[Required]
public string AgrupacionPoliticaId { get; set; } = null!;
[Required]
public int CategoriaId { get; set; }
public int? CategoriaId { get; set; }
public string? LogoUrl { get; set; }
public int? AmbitoGeograficoId { get; set; }
public int EleccionId { get; set; }
public int? EleccionId { get; set; }
}

View File

@@ -1,48 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Elecciones.Database.Migrations
{
/// <inheritdoc />
public partial class AddBancasPreviasTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "BancasPrevias",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
EleccionId = table.Column<int>(type: "int", nullable: false),
Camara = table.Column<int>(type: "int", nullable: false),
AgrupacionPoliticaId = table.Column<string>(type: "nvarchar(450)", nullable: false, collation: "Modern_Spanish_CI_AS"),
Cantidad = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BancasPrevias", x => x.Id);
table.ForeignKey(
name: "FK_BancasPrevias_AgrupacionesPoliticas_AgrupacionPoliticaId",
column: x => x.AgrupacionPoliticaId,
principalTable: "AgrupacionesPoliticas",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_BancasPrevias_AgrupacionPoliticaId",
table: "BancasPrevias",
column: "AgrupacionPoliticaId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "BancasPrevias");
}
}
}

View File

@@ -1,38 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Elecciones.Database.Migrations
{
/// <inheritdoc />
public partial class AddOrdenNacionalToAgrupaciones : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "OrdenDiputadosNacionales",
table: "AgrupacionesPoliticas",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "OrdenSenadoresNacionales",
table: "AgrupacionesPoliticas",
type: "int",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "OrdenDiputadosNacionales",
table: "AgrupacionesPoliticas");
migrationBuilder.DropColumn(
name: "OrdenSenadoresNacionales",
table: "AgrupacionesPoliticas");
}
}
}

View File

@@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Elecciones.Database.Migrations
{
[DbContext(typeof(EleccionesDbContext))]
[Migration("20250924000007_AddOrdenNacionalToAgrupaciones")]
partial class AddOrdenNacionalToAgrupaciones
[Migration("20250929124756_LegislativasNacionales2025")]
partial class LegislativasNacionales2025
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -29,11 +29,8 @@ namespace Elecciones.Database.Migrations
modelBuilder.Entity("Eleccion", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("DistritoId")
.IsRequired()
.HasColumnType("nvarchar(max)");
@@ -642,12 +639,20 @@ namespace Elecciones.Database.Migrations
modelBuilder.Entity("Elecciones.Database.Entities.EstadoRecuentoGeneral", b =>
{
b.HasOne("Elecciones.Database.Entities.AmbitoGeografico", "AmbitoGeografico")
.WithMany()
.HasForeignKey("AmbitoGeograficoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Elecciones.Database.Entities.CategoriaElectoral", "CategoriaElectoral")
.WithMany()
.HasForeignKey("CategoriaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("AmbitoGeografico");
b.Navigation("CategoriaElectoral");
});

View File

@@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace Elecciones.Database.Migrations
{
/// <inheritdoc />
public partial class AddEleccionEntities : Migration
public partial class LegislativasNacionales2025 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
@@ -81,12 +81,45 @@ namespace Elecciones.Database.Migrations
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "OrdenDiputadosNacionales",
table: "AgrupacionesPoliticas",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "OrdenSenadoresNacionales",
table: "AgrupacionesPoliticas",
type: "int",
nullable: true);
migrationBuilder.CreateTable(
name: "Elecciones",
name: "BancasPrevias",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
EleccionId = table.Column<int>(type: "int", nullable: false),
Camara = table.Column<int>(type: "int", nullable: false),
AgrupacionPoliticaId = table.Column<string>(type: "nvarchar(450)", nullable: false, collation: "Modern_Spanish_CI_AS"),
Cantidad = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BancasPrevias", x => x.Id);
table.ForeignKey(
name: "FK_BancasPrevias_AgrupacionesPoliticas_AgrupacionPoliticaId",
column: x => x.AgrupacionPoliticaId,
principalTable: "AgrupacionesPoliticas",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Elecciones",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false),
Nombre = table.Column<string>(type: "nvarchar(max)", nullable: false),
Nivel = table.Column<string>(type: "nvarchar(max)", nullable: false),
DistritoId = table.Column<string>(type: "nvarchar(max)", nullable: false),
@@ -96,11 +129,31 @@ namespace Elecciones.Database.Migrations
{
table.PrimaryKey("PK_Elecciones", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_BancasPrevias_AgrupacionPoliticaId",
table: "BancasPrevias",
column: "AgrupacionPoliticaId");
migrationBuilder.AddForeignKey(
name: "FK_EstadosRecuentosGenerales_AmbitosGeograficos_AmbitoGeograficoId",
table: "EstadosRecuentosGenerales",
column: "AmbitoGeograficoId",
principalTable: "AmbitosGeograficos",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_EstadosRecuentosGenerales_AmbitosGeograficos_AmbitoGeograficoId",
table: "EstadosRecuentosGenerales");
migrationBuilder.DropTable(
name: "BancasPrevias");
migrationBuilder.DropTable(
name: "Elecciones");
@@ -143,6 +196,14 @@ namespace Elecciones.Database.Migrations
migrationBuilder.DropColumn(
name: "EleccionId",
table: "Bancadas");
migrationBuilder.DropColumn(
name: "OrdenDiputadosNacionales",
table: "AgrupacionesPoliticas");
migrationBuilder.DropColumn(
name: "OrdenSenadoresNacionales",
table: "AgrupacionesPoliticas");
}
}
}

View File

@@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Elecciones.Database.Migrations
{
[DbContext(typeof(EleccionesDbContext))]
[Migration("20250922213437_AddBancasPreviasTable")]
partial class AddBancasPreviasTable
[Migration("20250929153202_MakeCategoriaIdNullableInLogos")]
partial class MakeCategoriaIdNullableInLogos
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -29,11 +29,8 @@ namespace Elecciones.Database.Migrations
modelBuilder.Entity("Eleccion", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("DistritoId")
.IsRequired()
.HasColumnType("nvarchar(max)");
@@ -102,9 +99,15 @@ namespace Elecciones.Database.Migrations
b.Property<int?>("OrdenDiputados")
.HasColumnType("int");
b.Property<int?>("OrdenDiputadosNacionales")
.HasColumnType("int");
b.Property<int?>("OrdenSenadores")
.HasColumnType("int");
b.Property<int?>("OrdenSenadoresNacionales")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("AgrupacionesPoliticas");
@@ -636,12 +639,20 @@ namespace Elecciones.Database.Migrations
modelBuilder.Entity("Elecciones.Database.Entities.EstadoRecuentoGeneral", b =>
{
b.HasOne("Elecciones.Database.Entities.AmbitoGeografico", "AmbitoGeografico")
.WithMany()
.HasForeignKey("AmbitoGeograficoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Elecciones.Database.Entities.CategoriaElectoral", "CategoriaElectoral")
.WithMany()
.HasForeignKey("CategoriaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("AmbitoGeografico");
b.Navigation("CategoriaElectoral");
});

View File

@@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Elecciones.Database.Migrations
{
/// <inheritdoc />
public partial class MakeCategoriaIdNullableInLogos : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Elecciones.Database.Migrations
{
[DbContext(typeof(EleccionesDbContext))]
[Migration("20250911152547_AddEleccionEntities")]
partial class AddEleccionEntities
[Migration("20250929163650_FixLogoCategoriaNullability")]
partial class FixLogoCategoriaNullability
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -29,11 +29,8 @@ namespace Elecciones.Database.Migrations
modelBuilder.Entity("Eleccion", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("DistritoId")
.IsRequired()
.HasColumnType("nvarchar(max)");
@@ -102,9 +99,15 @@ namespace Elecciones.Database.Migrations
b.Property<int?>("OrdenDiputados")
.HasColumnType("int");
b.Property<int?>("OrdenDiputadosNacionales")
.HasColumnType("int");
b.Property<int?>("OrdenSenadores")
.HasColumnType("int");
b.Property<int?>("OrdenSenadoresNacionales")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("AgrupacionesPoliticas");
@@ -151,6 +154,35 @@ namespace Elecciones.Database.Migrations
b.ToTable("AmbitosGeograficos");
});
modelBuilder.Entity("Elecciones.Database.Entities.BancaPrevia", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AgrupacionPoliticaId")
.IsRequired()
.HasColumnType("nvarchar(450)")
.UseCollation("Modern_Spanish_CI_AS");
b.Property<int>("Camara")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<int>("EleccionId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("AgrupacionPoliticaId");
b.ToTable("BancasPrevias");
});
modelBuilder.Entity("Elecciones.Database.Entities.Bancada", b =>
{
b.Property<int>("Id")
@@ -369,7 +401,7 @@ namespace Elecciones.Database.Migrations
b.Property<int>("CategoriaId")
.HasColumnType("int");
b.Property<int>("EleccionId")
b.Property<int?>("EleccionId")
.HasColumnType("int");
b.Property<string>("LogoUrl")
@@ -549,6 +581,17 @@ namespace Elecciones.Database.Migrations
b.ToTable("Telegramas");
});
modelBuilder.Entity("Elecciones.Database.Entities.BancaPrevia", b =>
{
b.HasOne("Elecciones.Database.Entities.AgrupacionPolitica", "AgrupacionPolitica")
.WithMany()
.HasForeignKey("AgrupacionPoliticaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("AgrupacionPolitica");
});
modelBuilder.Entity("Elecciones.Database.Entities.Bancada", b =>
{
b.HasOne("Elecciones.Database.Entities.AgrupacionPolitica", "AgrupacionPolitica")
@@ -596,12 +639,20 @@ namespace Elecciones.Database.Migrations
modelBuilder.Entity("Elecciones.Database.Entities.EstadoRecuentoGeneral", b =>
{
b.HasOne("Elecciones.Database.Entities.AmbitoGeografico", "AmbitoGeografico")
.WithMany()
.HasForeignKey("AmbitoGeograficoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Elecciones.Database.Entities.CategoriaElectoral", "CategoriaElectoral")
.WithMany()
.HasForeignKey("CategoriaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("AmbitoGeografico");
b.Navigation("CategoriaElectoral");
});

View File

@@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Elecciones.Database.Migrations
{
/// <inheritdoc />
public partial class FixLogoCategoriaNullability : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "CategoriaId",
table: "LogosAgrupacionesCategorias",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "CategoriaId",
table: "LogosAgrupacionesCategorias",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
}
}
}

View File

@@ -26,11 +26,8 @@ namespace Elecciones.Database.Migrations
modelBuilder.Entity("Eleccion", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("DistritoId")
.IsRequired()
.HasColumnType("nvarchar(max)");
@@ -401,7 +398,7 @@ namespace Elecciones.Database.Migrations
b.Property<int>("CategoriaId")
.HasColumnType("int");
b.Property<int>("EleccionId")
b.Property<int?>("EleccionId")
.HasColumnType("int");
b.Property<string>("LogoUrl")
@@ -639,12 +636,20 @@ namespace Elecciones.Database.Migrations
modelBuilder.Entity("Elecciones.Database.Entities.EstadoRecuentoGeneral", b =>
{
b.HasOne("Elecciones.Database.Entities.AmbitoGeografico", "AmbitoGeografico")
.WithMany()
.HasForeignKey("AmbitoGeograficoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Elecciones.Database.Entities.CategoriaElectoral", "CategoriaElectoral")
.WithMany()
.HasForeignKey("CategoriaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("AmbitoGeografico");
b.Navigation("CategoriaElectoral");
});

View File

@@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Elecciones.Database")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+67634ae947197595f6f644f3a80a982dd3573dfb")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+3b0eee25e6441da1831442a90b6552cc8ef59d07")]
[assembly: System.Reflection.AssemblyProductAttribute("Elecciones.Database")]
[assembly: System.Reflection.AssemblyTitleAttribute("Elecciones.Database")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]