Feat Widgets Cards y Optimización de Consultas
This commit is contained in:
@@ -92,6 +92,36 @@ public class AdminController : ControllerBase
|
||||
return Ok();
|
||||
}
|
||||
|
||||
// --- ENDPOINTS PARA NACIONALES ---
|
||||
|
||||
[HttpPut("agrupaciones/orden-diputados-nacionales")]
|
||||
public async Task<IActionResult> UpdateDiputadosNacionalesOrden([FromBody] List<string> idsAgrupacionesOrdenadas)
|
||||
{
|
||||
await _dbContext.AgrupacionesPoliticas.ExecuteUpdateAsync(s => s.SetProperty(a => a.OrdenDiputadosNacionales, (int?)null));
|
||||
|
||||
for (int i = 0; i < idsAgrupacionesOrdenadas.Count; i++)
|
||||
{
|
||||
var agrupacion = await _dbContext.AgrupacionesPoliticas.FindAsync(idsAgrupacionesOrdenadas[i]);
|
||||
if (agrupacion != null) agrupacion.OrdenDiputadosNacionales = i + 1;
|
||||
}
|
||||
await _dbContext.SaveChangesAsync();
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPut("agrupaciones/orden-senadores-nacionales")]
|
||||
public async Task<IActionResult> UpdateSenadoresNacionalesOrden([FromBody] List<string> idsAgrupacionesOrdenadas)
|
||||
{
|
||||
await _dbContext.AgrupacionesPoliticas.ExecuteUpdateAsync(s => s.SetProperty(a => a.OrdenSenadoresNacionales, (int?)null));
|
||||
|
||||
for (int i = 0; i < idsAgrupacionesOrdenadas.Count; i++)
|
||||
{
|
||||
var agrupacion = await _dbContext.AgrupacionesPoliticas.FindAsync(idsAgrupacionesOrdenadas[i]);
|
||||
if (agrupacion != null) agrupacion.OrdenSenadoresNacionales = i + 1;
|
||||
}
|
||||
await _dbContext.SaveChangesAsync();
|
||||
return Ok();
|
||||
}
|
||||
|
||||
// LEER todas las configuraciones
|
||||
[HttpGet("configuracion")]
|
||||
public async Task<IActionResult> GetConfiguracion()
|
||||
@@ -125,14 +155,15 @@ public class AdminController : ControllerBase
|
||||
|
||||
// LEER: Obtener todas las bancadas para una cámara, con su partido y ocupante actual
|
||||
[HttpGet("bancadas/{camara}")]
|
||||
public async Task<IActionResult> GetBancadas(TipoCamara camara)
|
||||
public async Task<IActionResult> GetBancadas(TipoCamara camara, [FromQuery] int eleccionId)
|
||||
{
|
||||
// 3. La lógica interna se mantiene igual, ya que filtra por ambos parámetros.
|
||||
var bancadas = await _dbContext.Bancadas
|
||||
.AsNoTracking()
|
||||
.Include(b => b.AgrupacionPolitica)
|
||||
.Include(b => b.Ocupante)
|
||||
.Where(b => b.Camara == camara)
|
||||
.OrderBy(b => b.Id) // Ordenar por ID para consistencia
|
||||
.Where(b => b.EleccionId == eleccionId && b.Camara == camara)
|
||||
.OrderBy(b => b.NumeroBanca)
|
||||
.ToListAsync();
|
||||
|
||||
return Ok(bancadas);
|
||||
@@ -181,10 +212,39 @@ public class AdminController : ControllerBase
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
[HttpGet("logos")]
|
||||
public async Task<IActionResult> GetLogos()
|
||||
[HttpGet("catalogos/provincias")]
|
||||
public async Task<IActionResult> GetProvinciasForAdmin()
|
||||
{
|
||||
return Ok(await _dbContext.LogosAgrupacionesCategorias.AsNoTracking().ToListAsync());
|
||||
var provincias = await _dbContext.AmbitosGeograficos
|
||||
.AsNoTracking()
|
||||
.Where(a => a.NivelId == 10) // Nivel 10 = Provincia
|
||||
.OrderBy(a => a.Nombre)
|
||||
.Select(a => new { Id = a.Id.ToString(), Nombre = a.Nombre })
|
||||
.ToListAsync();
|
||||
return Ok(provincias);
|
||||
}
|
||||
|
||||
// --- ENDPOINTS MODIFICADOS ---
|
||||
|
||||
[HttpGet("logos")]
|
||||
public async Task<IActionResult> GetLogos([FromQuery] int eleccionId)
|
||||
{
|
||||
// Añadimos el filtro por EleccionId
|
||||
return Ok(await _dbContext.LogosAgrupacionesCategorias
|
||||
.AsNoTracking()
|
||||
.Where(l => l.EleccionId == eleccionId)
|
||||
.ToListAsync());
|
||||
}
|
||||
|
||||
[HttpGet("candidatos")]
|
||||
public async Task<IActionResult> GetCandidatos([FromQuery] int eleccionId)
|
||||
{
|
||||
// Añadimos el filtro por EleccionId
|
||||
var candidatos = await _dbContext.CandidatosOverrides
|
||||
.AsNoTracking()
|
||||
.Where(c => c.EleccionId == eleccionId)
|
||||
.ToListAsync();
|
||||
return Ok(candidatos);
|
||||
}
|
||||
|
||||
[HttpPut("logos")]
|
||||
@@ -239,18 +299,6 @@ public class AdminController : ControllerBase
|
||||
return Ok(municipios);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Obtiene todos los overrides de candidatos configurados.
|
||||
/// </summary>
|
||||
[HttpGet("candidatos")]
|
||||
public async Task<IActionResult> GetCandidatos()
|
||||
{
|
||||
var candidatos = await _dbContext.CandidatosOverrides
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
return Ok(candidatos);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Guarda (actualiza o crea) una lista de overrides de candidatos.
|
||||
/// </summary>
|
||||
@@ -337,4 +385,40 @@ public class AdminController : ControllerBase
|
||||
_logger.LogWarning("El nivel de logging ha sido cambiado a: {Level}", request.Level);
|
||||
return Ok(new { message = $"Nivel de logging actualizado a '{request.Level}'." });
|
||||
}
|
||||
|
||||
// LEER todas las bancas previas para una elección
|
||||
[HttpGet("bancas-previas/{eleccionId}")]
|
||||
public async Task<IActionResult> GetBancasPrevias(int eleccionId)
|
||||
{
|
||||
var bancas = await _dbContext.BancasPrevias
|
||||
.AsNoTracking()
|
||||
.Where(b => b.EleccionId == eleccionId)
|
||||
.Include(b => b.AgrupacionPolitica)
|
||||
.ToListAsync();
|
||||
return Ok(bancas);
|
||||
}
|
||||
|
||||
// GUARDAR (Upsert) una lista de bancas previas
|
||||
[HttpPut("bancas-previas/{eleccionId}")]
|
||||
public async Task<IActionResult> UpdateBancasPrevias(int eleccionId, [FromBody] List<BancaPrevia> bancas)
|
||||
{
|
||||
// Borramos los registros existentes para esta elección para simplificar la lógica
|
||||
await _dbContext.BancasPrevias.Where(b => b.EleccionId == eleccionId).ExecuteDeleteAsync();
|
||||
|
||||
// Añadimos los nuevos registros que tienen al menos una banca
|
||||
foreach (var banca in bancas.Where(b => b.Cantidad > 0))
|
||||
{
|
||||
_dbContext.BancasPrevias.Add(new BancaPrevia
|
||||
{
|
||||
EleccionId = eleccionId,
|
||||
Camara = banca.Camara,
|
||||
AgrupacionPoliticaId = banca.AgrupacionPoliticaId,
|
||||
Cantidad = banca.Cantidad
|
||||
});
|
||||
}
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
_logger.LogInformation("Se actualizaron las bancas previas para la EleccionId: {EleccionId}", eleccionId);
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
@@ -1208,13 +1208,16 @@ public class ResultadosController : ControllerBase
|
||||
|
||||
[HttpGet("mapa-resultados")]
|
||||
public async Task<IActionResult> GetResultadosMapaPorMunicipio(
|
||||
[FromRoute] int eleccionId,
|
||||
[FromQuery] int categoriaId,
|
||||
[FromQuery] string? distritoId = null)
|
||||
[FromRoute] int eleccionId,
|
||||
[FromQuery] int categoriaId,
|
||||
[FromQuery] string? distritoId = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(distritoId))
|
||||
{
|
||||
// --- VISTA NACIONAL (Ya corregida y funcionando) ---
|
||||
// --- VISTA NACIONAL (LÓGICA CORRECTA Y ROBUSTA) ---
|
||||
|
||||
// PASO 1: Agrupar y sumar los votos por provincia y partido directamente en la BD.
|
||||
// Esto crea una lista con los totales, que es mucho más pequeña que los datos crudos.
|
||||
var votosAgregadosPorProvincia = await _dbContext.ResultadosVotos
|
||||
.AsNoTracking()
|
||||
.Where(r => r.EleccionId == eleccionId
|
||||
@@ -1224,23 +1227,26 @@ public class ResultadosController : ControllerBase
|
||||
.GroupBy(r => new { r.AmbitoGeografico.DistritoId, r.AgrupacionPoliticaId })
|
||||
.Select(g => new
|
||||
{
|
||||
g.Key.DistritoId,
|
||||
g.Key.AgrupacionPoliticaId,
|
||||
DistritoId = g.Key.DistritoId!, // Sabemos que no es nulo por el .Where()
|
||||
AgrupacionPoliticaId = g.Key.AgrupacionPoliticaId,
|
||||
TotalVotos = g.Sum(r => r.CantidadVotos)
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var agrupacionesInfo = await _dbContext.AgrupacionesPoliticas.AsNoTracking().ToDictionaryAsync(a => a.Id);
|
||||
var provinciasInfo = await _dbContext.AmbitosGeograficos.AsNoTracking().Where(a => a.NivelId == 10).ToListAsync();
|
||||
|
||||
// PASO 2: Encontrar el ganador para cada provincia en la memoria de la aplicación.
|
||||
// Esto es muy rápido porque se hace sobre la lista ya agregada.
|
||||
var ganadoresPorProvincia = votosAgregadosPorProvincia
|
||||
.GroupBy(r => r.DistritoId)
|
||||
.Select(g => g.OrderByDescending(x => x.TotalVotos).First())
|
||||
.ToList();
|
||||
|
||||
// PASO 3: Obtener los datos adicionales (nombres, colores) para construir la respuesta final.
|
||||
var agrupacionesInfo = await _dbContext.AgrupacionesPoliticas.AsNoTracking().ToDictionaryAsync(a => a.Id);
|
||||
var provinciasInfo = await _dbContext.AmbitosGeograficos.AsNoTracking().Where(a => a.NivelId == 10).ToListAsync();
|
||||
|
||||
var mapaDataNacional = ganadoresPorProvincia.Select(g => new ResultadoMapaDto
|
||||
{
|
||||
AmbitoId = g.DistritoId!,
|
||||
AmbitoId = g.DistritoId,
|
||||
AmbitoNombre = provinciasInfo.FirstOrDefault(p => p.DistritoId == g.DistritoId)?.Nombre ?? "Desconocido",
|
||||
AgrupacionGanadoraId = g.AgrupacionPoliticaId,
|
||||
ColorGanador = agrupacionesInfo.GetValueOrDefault(g.AgrupacionPoliticaId)?.Color ?? "#808080"
|
||||
@@ -1250,16 +1256,13 @@ public class ResultadosController : ControllerBase
|
||||
}
|
||||
else
|
||||
{
|
||||
// --- VISTA PROVINCIAL (AHORA CORREGIDA CON LA MISMA LÓGICA) ---
|
||||
|
||||
// PASO 1: Agrupar por IDs y sumar votos en la base de datos.
|
||||
// --- VISTA PROVINCIAL (SIN CAMBIOS, YA ERA EFICIENTE) ---
|
||||
var votosAgregadosPorMunicipio = await _dbContext.ResultadosVotos
|
||||
.AsNoTracking()
|
||||
.Where(r => r.EleccionId == eleccionId
|
||||
&& r.CategoriaId == categoriaId
|
||||
&& r.AmbitoGeografico.DistritoId == distritoId
|
||||
&& r.AmbitoGeografico.NivelId == 30)
|
||||
// Agrupamos por los IDs (int y string)
|
||||
.GroupBy(r => new { r.AmbitoGeograficoId, r.AgrupacionPoliticaId })
|
||||
.Select(g => new
|
||||
{
|
||||
@@ -1269,13 +1272,11 @@ public class ResultadosController : ControllerBase
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
// PASO 2: Encontrar el ganador para cada municipio en memoria.
|
||||
var ganadoresPorMunicipio = votosAgregadosPorMunicipio
|
||||
.GroupBy(r => r.AmbitoGeograficoId)
|
||||
.Select(g => g.OrderByDescending(x => x.TotalVotos).First())
|
||||
.ToList();
|
||||
|
||||
// PASO 3: Hidratar con los nombres y colores (muy rápido).
|
||||
var idsMunicipios = ganadoresPorMunicipio.Select(g => g.AmbitoGeograficoId).ToList();
|
||||
var idsAgrupaciones = ganadoresPorMunicipio.Select(g => g.AgrupacionPoliticaId).ToList();
|
||||
|
||||
@@ -1285,7 +1286,6 @@ public class ResultadosController : ControllerBase
|
||||
var agrupacionesInfo = await _dbContext.AgrupacionesPoliticas.AsNoTracking()
|
||||
.Where(a => idsAgrupaciones.Contains(a.Id)).ToDictionaryAsync(a => a.Id);
|
||||
|
||||
// Mapeo final a DTO.
|
||||
var mapaDataProvincial = ganadoresPorMunicipio.Select(g => new ResultadoMapaDto
|
||||
{
|
||||
AmbitoId = g.AmbitoGeograficoId.ToString(),
|
||||
@@ -1297,4 +1297,193 @@ public class ResultadosController : ControllerBase
|
||||
return Ok(mapaDataProvincial);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("composicion-nacional")]
|
||||
public async Task<IActionResult> GetComposicionNacional([FromRoute] int eleccionId)
|
||||
{
|
||||
// 1. Obtener todas las configuraciones relevantes en una sola consulta.
|
||||
var config = await _dbContext.Configuraciones.AsNoTracking().ToDictionaryAsync(c => c.Clave, c => c.Valor);
|
||||
|
||||
// 2. Obtener todas las agrupaciones políticas en una sola consulta.
|
||||
var todasAgrupaciones = await _dbContext.AgrupacionesPoliticas.AsNoTracking().ToDictionaryAsync(a => a.Id);
|
||||
|
||||
// 3. Obtener las bancas PREVIAS (las que no están en juego).
|
||||
var bancasPrevias = await _dbContext.BancasPrevias
|
||||
.AsNoTracking()
|
||||
.Where(b => b.EleccionId == eleccionId)
|
||||
.ToListAsync();
|
||||
|
||||
// 4. Obtener las bancas EN JUEGO (proyectadas por provincia).
|
||||
var proyecciones = await _dbContext.ProyeccionesBancas
|
||||
.AsNoTracking()
|
||||
.Where(p => p.EleccionId == eleccionId && p.AmbitoGeografico.NivelId == 10) // Nivel 10 = Ámbito Provincial
|
||||
.ToListAsync();
|
||||
|
||||
//Calculamos la fecha de la última proyección.
|
||||
// Si no hay proyecciones aún, usamos la fecha y hora actual como un fallback seguro.
|
||||
var ultimaActualizacion = proyecciones.Any()
|
||||
? proyecciones.Max(p => p.FechaTotalizacion)
|
||||
: DateTime.UtcNow;
|
||||
|
||||
// 5. Combinar los datos para obtener la composición final de cada partido.
|
||||
var composicionFinal = todasAgrupaciones.Values.Select(agrupacion => new
|
||||
{
|
||||
Agrupacion = agrupacion,
|
||||
DiputadosFijos = bancasPrevias.FirstOrDefault(b => b.AgrupacionPoliticaId == agrupacion.Id && b.Camara == Core.Enums.TipoCamara.Diputados)?.Cantidad ?? 0,
|
||||
DiputadosGanados = proyecciones.Where(p => p.AgrupacionPoliticaId == agrupacion.Id && p.CategoriaId == 2).Sum(p => p.NroBancas),
|
||||
SenadoresFijos = bancasPrevias.FirstOrDefault(b => b.AgrupacionPoliticaId == agrupacion.Id && b.Camara == Core.Enums.TipoCamara.Senadores)?.Cantidad ?? 0,
|
||||
SenadoresGanados = proyecciones.Where(p => p.AgrupacionPoliticaId == agrupacion.Id && p.CategoriaId == 1).Sum(p => p.NroBancas)
|
||||
})
|
||||
.Select(r => new
|
||||
{
|
||||
r.Agrupacion,
|
||||
r.DiputadosFijos,
|
||||
r.DiputadosGanados,
|
||||
DiputadosTotales = r.DiputadosFijos + r.DiputadosGanados,
|
||||
r.SenadoresFijos,
|
||||
r.SenadoresGanados,
|
||||
SenadoresTotales = r.SenadoresFijos + r.SenadoresGanados
|
||||
})
|
||||
.ToList();
|
||||
|
||||
// 6. Determinar la información de la presidencia para cada cámara.
|
||||
config.TryGetValue("PresidenciaDiputadosNacional", out var idPartidoPresDip);
|
||||
var partidoPresidenteDiputados = !string.IsNullOrEmpty(idPartidoPresDip) ? todasAgrupaciones.GetValueOrDefault(idPartidoPresDip) : null;
|
||||
config.TryGetValue("PresidenciaDiputadosNacional_TipoBanca", out var tipoBancaDip);
|
||||
|
||||
config.TryGetValue("PresidenciaSenadoNacional", out var idPartidoPresSen);
|
||||
var partidoPresidenteSenadores = !string.IsNullOrEmpty(idPartidoPresSen) ? todasAgrupaciones.GetValueOrDefault(idPartidoPresSen) : null;
|
||||
config.TryGetValue("PresidenciaSenadoNacional_TipoBanca", out var tipoBancaSen);
|
||||
|
||||
|
||||
// 7. Construir el objeto de respuesta final para D Diputados
|
||||
var diputados = new
|
||||
{
|
||||
CamaraNombre = "Cámara de Diputados",
|
||||
TotalBancas = 257,
|
||||
BancasEnJuego = 127,
|
||||
UltimaActualizacion = ultimaActualizacion,
|
||||
Partidos = composicionFinal
|
||||
.Where(p => p.DiputadosTotales > 0)
|
||||
.OrderByDescending(p => p.DiputadosTotales)
|
||||
.Select(p => new
|
||||
{
|
||||
p.Agrupacion.Id,
|
||||
p.Agrupacion.Nombre,
|
||||
p.Agrupacion.NombreCorto,
|
||||
p.Agrupacion.Color,
|
||||
BancasFijos = p.DiputadosFijos,
|
||||
BancasGanadas = p.DiputadosGanados,
|
||||
BancasTotales = p.DiputadosTotales,
|
||||
p.Agrupacion.OrdenDiputadosNacionales,
|
||||
p.Agrupacion.OrdenSenadoresNacionales
|
||||
}).ToList(),
|
||||
PresidenteBancada = partidoPresidenteDiputados != null
|
||||
? new { Color = partidoPresidenteDiputados.Color, TipoBanca = tipoBancaDip ?? "ganada" }
|
||||
: null
|
||||
};
|
||||
|
||||
// 8. Construir el objeto de respuesta final para Senadores
|
||||
var senadores = new
|
||||
{
|
||||
CamaraNombre = "Senado de la Nación",
|
||||
TotalBancas = 72,
|
||||
BancasEnJuego = 24,
|
||||
UltimaActualizacion = ultimaActualizacion,
|
||||
Partidos = composicionFinal
|
||||
.Where(p => p.SenadoresTotales > 0)
|
||||
.OrderByDescending(p => p.SenadoresTotales)
|
||||
.Select(p => new
|
||||
{
|
||||
p.Agrupacion.Id,
|
||||
p.Agrupacion.Nombre,
|
||||
p.Agrupacion.NombreCorto,
|
||||
p.Agrupacion.Color,
|
||||
BancasFijos = p.SenadoresFijos,
|
||||
BancasGanadas = p.SenadoresGanados,
|
||||
BancasTotales = p.SenadoresTotales,
|
||||
p.Agrupacion.OrdenDiputadosNacionales,
|
||||
p.Agrupacion.OrdenSenadoresNacionales
|
||||
}).ToList(),
|
||||
PresidenteBancada = partidoPresidenteSenadores != null
|
||||
? new { Color = partidoPresidenteSenadores.Color, TipoBanca = tipoBancaSen ?? "ganada" }
|
||||
: null
|
||||
};
|
||||
|
||||
return Ok(new { Diputados = diputados, Senadores = senadores });
|
||||
}
|
||||
|
||||
[HttpGet("resumen-por-provincia")]
|
||||
public async Task<IActionResult> GetResumenPorProvincia([FromRoute] int eleccionId)
|
||||
{
|
||||
const int categoriaDiputadosNacionales = 2;
|
||||
|
||||
var todasLasProyecciones = await _dbContext.ProyeccionesBancas.AsNoTracking()
|
||||
.Where(p => p.EleccionId == eleccionId && p.CategoriaId == categoriaDiputadosNacionales)
|
||||
.ToDictionaryAsync(p => p.AmbitoGeograficoId + "_" + p.AgrupacionPoliticaId);
|
||||
|
||||
var todosLosOverrides = await _dbContext.CandidatosOverrides.AsNoTracking()
|
||||
.Where(c => c.EleccionId == eleccionId && c.CategoriaId == categoriaDiputadosNacionales)
|
||||
.ToListAsync();
|
||||
|
||||
var todosLosLogos = await _dbContext.LogosAgrupacionesCategorias.AsNoTracking()
|
||||
.Where(l => l.EleccionId == eleccionId && l.CategoriaId == categoriaDiputadosNacionales)
|
||||
.ToListAsync();
|
||||
|
||||
var datosBrutos = await _dbContext.AmbitosGeograficos.AsNoTracking()
|
||||
.Where(a => a.NivelId == 10)
|
||||
.Select(provincia => new
|
||||
{
|
||||
ProvinciaAmbitoId = provincia.Id,
|
||||
ProvinciaDistritoId = provincia.DistritoId!,
|
||||
ProvinciaNombre = provincia.Nombre,
|
||||
EstadoRecuento = _dbContext.EstadosRecuentosGenerales
|
||||
.Where(e => e.EleccionId == eleccionId && e.CategoriaId == categoriaDiputadosNacionales && e.AmbitoGeograficoId == provincia.Id)
|
||||
.Select(e => new EstadoRecuentoDto { /* ... */ })
|
||||
.FirstOrDefault(),
|
||||
ResultadosBrutos = _dbContext.ResultadosVotos
|
||||
.Where(r => r.EleccionId == eleccionId && r.CategoriaId == categoriaDiputadosNacionales && r.AmbitoGeografico.DistritoId == provincia.DistritoId)
|
||||
.GroupBy(r => r.AgrupacionPolitica)
|
||||
.Select(g => new { Agrupacion = g.Key, Votos = g.Sum(r => r.CantidadVotos) })
|
||||
.OrderByDescending(x => x.Votos)
|
||||
.Take(2)
|
||||
.ToList()
|
||||
})
|
||||
.OrderBy(p => p.ProvinciaNombre)
|
||||
.ToListAsync();
|
||||
|
||||
var resultadosFinales = datosBrutos.Select(provinciaData =>
|
||||
{
|
||||
var totalVotosProvincia = (decimal)provinciaData.ResultadosBrutos.Sum(r => r.Votos);
|
||||
return new ResumenProvinciaDto
|
||||
{
|
||||
ProvinciaId = provinciaData.ProvinciaDistritoId,
|
||||
ProvinciaNombre = provinciaData.ProvinciaNombre,
|
||||
EstadoRecuento = provinciaData.EstadoRecuento,
|
||||
Resultados = provinciaData.ResultadosBrutos.Select(r =>
|
||||
{
|
||||
var provinciaAmbitoId = provinciaData.ProvinciaAmbitoId;
|
||||
return new ResultadoCandidatoDto
|
||||
{
|
||||
AgrupacionId = r.Agrupacion.Id,
|
||||
NombreAgrupacion = r.Agrupacion.NombreCorto ?? r.Agrupacion.Nombre,
|
||||
Color = r.Agrupacion.Color,
|
||||
Votos = r.Votos,
|
||||
NombreCandidato = (todosLosOverrides.FirstOrDefault(c => c.AgrupacionPoliticaId == r.Agrupacion.Id && c.AmbitoGeograficoId == provinciaAmbitoId)
|
||||
?? todosLosOverrides.FirstOrDefault(c => c.AgrupacionPoliticaId == r.Agrupacion.Id && c.AmbitoGeograficoId == null))
|
||||
?.NombreCandidato,
|
||||
FotoUrl = (todosLosLogos.FirstOrDefault(l => l.AgrupacionPoliticaId == r.Agrupacion.Id && l.AmbitoGeograficoId == provinciaAmbitoId)
|
||||
?? todosLosLogos.FirstOrDefault(l => l.AgrupacionPoliticaId == r.Agrupacion.Id && l.AmbitoGeograficoId == null))
|
||||
?.LogoUrl,
|
||||
BancasObtenidas = todasLasProyecciones.ContainsKey(provinciaAmbitoId + "_" + r.Agrupacion.Id)
|
||||
? todasLasProyecciones[provinciaAmbitoId + "_" + r.Agrupacion.Id].NroBancas
|
||||
: 0,
|
||||
Porcentaje = totalVotosProvincia > 0 ? (r.Votos / totalVotosProvincia) * 100 : 0
|
||||
};
|
||||
}).ToList()
|
||||
};
|
||||
}).ToList();
|
||||
|
||||
return Ok(resultadosFinales);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ using Microsoft.IdentityModel.Tokens;
|
||||
using Elecciones.Database.Entities;
|
||||
using System.Text.Json.Serialization;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Elecciones.Core.Enums;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
// Esta es la estructura estándar y recomendada.
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@@ -81,8 +83,40 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
});
|
||||
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
//builder.Services.AddSwaggerGen();
|
||||
|
||||
builder.Services.AddSwaggerGen(options =>
|
||||
{
|
||||
// 1. Definir el esquema de seguridad que usaremos (Bearer Token)
|
||||
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
|
||||
{
|
||||
Description = "Autorización JWT usando el esquema Bearer. Ingresa 'Bearer' [espacio] y luego tu token. Ejemplo: 'Bearer 12345abcdef'",
|
||||
Name = "Authorization", // El nombre del header HTTP
|
||||
In = ParameterLocation.Header, // Dónde se ubicará el token (en el header)
|
||||
Type = SecuritySchemeType.ApiKey, // El tipo de esquema
|
||||
Scheme = "Bearer" // El nombre del esquema
|
||||
});
|
||||
|
||||
// 2. Aplicar este requisito de seguridad a todos los endpoints que lo necesiten
|
||||
options.AddSecurityRequirement(new OpenApiSecurityRequirement()
|
||||
{
|
||||
{
|
||||
new OpenApiSecurityScheme
|
||||
{
|
||||
Reference = new OpenApiReference
|
||||
{
|
||||
Type = ReferenceType.SecurityScheme,
|
||||
Id = "Bearer" // Debe coincidir con el nombre que le dimos en AddSecurityDefinition
|
||||
},
|
||||
Scheme = "oauth2",
|
||||
Name = "Bearer",
|
||||
In = ParameterLocation.Header,
|
||||
},
|
||||
new List<string>()
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
builder.Services.Configure<ForwardedHeadersOptions>(options =>
|
||||
{
|
||||
@@ -153,7 +187,23 @@ using (var scope = app.Services.CreateScope())
|
||||
}
|
||||
}
|
||||
|
||||
// Seeder para las bancas vacías
|
||||
// --- SEEDER DE ELECCIONES (Añadir para asegurar que existan) ---
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var context = scope.ServiceProvider.GetRequiredService<EleccionesDbContext>();
|
||||
if (!context.Elecciones.Any())
|
||||
{
|
||||
context.Elecciones.AddRange(
|
||||
new Eleccion { Id = 1, Nombre = "Elecciones Provinciales 2025", Nivel = "Provincial", DistritoId = "02", Fecha = new DateOnly(2025, 10, 26) },
|
||||
new Eleccion { Id = 2, Nombre = "Elecciones Nacionales 2025", Nivel = "Nacional", DistritoId = "00", Fecha = new DateOnly(2025, 10, 26) }
|
||||
);
|
||||
context.SaveChanges();
|
||||
Console.WriteLine("--> Seeded Eleccion entities.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --- SEEDER DE BANCAS (MODIFICADO Y COMPLETADO) ---
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var services = scope.ServiceProvider;
|
||||
@@ -161,27 +211,91 @@ using (var scope = app.Services.CreateScope())
|
||||
if (!context.Bancadas.Any())
|
||||
{
|
||||
var bancas = new List<Bancada>();
|
||||
// 92 bancas de diputados
|
||||
for (int i = 1; i <= 92; i++) // Bucle de 1 a 92
|
||||
|
||||
// --- BANCAS PROVINCIALES (EleccionId = 1) ---
|
||||
// 92 bancas de diputados provinciales
|
||||
for (int i = 1; i <= 92; i++)
|
||||
{
|
||||
bancas.Add(new Bancada
|
||||
{
|
||||
EleccionId = 1,
|
||||
Camara = Elecciones.Core.Enums.TipoCamara.Diputados,
|
||||
NumeroBanca = i // Asignamos el número de banca
|
||||
NumeroBanca = i
|
||||
});
|
||||
}
|
||||
// 46 bancas de senadores
|
||||
for (int i = 1; i <= 46; i++) // Bucle de 1 a 46
|
||||
// 46 bancas de senadores provinciales
|
||||
for (int i = 1; i <= 46; i++)
|
||||
{
|
||||
bancas.Add(new Bancada
|
||||
{
|
||||
EleccionId = 1,
|
||||
Camara = Elecciones.Core.Enums.TipoCamara.Senadores,
|
||||
NumeroBanca = i // Asignamos el número de banca
|
||||
NumeroBanca = i
|
||||
});
|
||||
}
|
||||
|
||||
// --- BANCAS NACIONALES (EleccionId = 2) ---
|
||||
// 257 bancas de diputados nacionales
|
||||
for (int i = 1; i <= 257; i++)
|
||||
{
|
||||
bancas.Add(new Bancada
|
||||
{
|
||||
EleccionId = 2,
|
||||
Camara = TipoCamara.Diputados,
|
||||
NumeroBanca = i
|
||||
});
|
||||
}
|
||||
// 72 bancas de senadores nacionales
|
||||
for (int i = 1; i <= 72; i++)
|
||||
{
|
||||
bancas.Add(new Bancada
|
||||
{
|
||||
EleccionId = 2,
|
||||
Camara = TipoCamara.Senadores,
|
||||
NumeroBanca = i
|
||||
});
|
||||
}
|
||||
|
||||
context.Bancadas.AddRange(bancas);
|
||||
context.SaveChanges();
|
||||
Console.WriteLine("--> Seeded 138 bancas físicas.");
|
||||
Console.WriteLine($"--> Seeded {bancas.Count} bancas físicas para ambas elecciones.");
|
||||
}
|
||||
}
|
||||
|
||||
// --- Seeder para Proyecciones de Bancas (Elección Nacional) ---
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var services = scope.ServiceProvider;
|
||||
var context = services.GetRequiredService<EleccionesDbContext>();
|
||||
|
||||
const int eleccionNacionalId = 2;
|
||||
// Categoría 2: Diputados Nacionales, Categoría 1: Senadores Nacionales
|
||||
if (!context.ProyeccionesBancas.Any(p => p.EleccionId == eleccionNacionalId))
|
||||
{
|
||||
var partidos = await context.AgrupacionesPoliticas.Take(5).ToListAsync();
|
||||
var provincia = await context.AmbitosGeograficos.FirstOrDefaultAsync(a => a.NivelId == 10); // Asumimos un ámbito provincial genérico para la proyección total
|
||||
|
||||
if (partidos.Count >= 5 && provincia != null)
|
||||
{
|
||||
var proyecciones = new List<ProyeccionBanca>
|
||||
{
|
||||
// -- DIPUTADOS (Se renuevan 127) --
|
||||
new() { EleccionId = eleccionNacionalId, CategoriaId = 2, AmbitoGeograficoId = provincia.Id, AgrupacionPoliticaId = partidos[0].Id, NroBancas = 50, FechaTotalizacion = DateTime.UtcNow },
|
||||
new() { EleccionId = eleccionNacionalId, CategoriaId = 2, AmbitoGeograficoId = provincia.Id, AgrupacionPoliticaId = partidos[1].Id, NroBancas = 40, FechaTotalizacion = DateTime.UtcNow },
|
||||
new() { EleccionId = eleccionNacionalId, CategoriaId = 2, AmbitoGeograficoId = provincia.Id, AgrupacionPoliticaId = partidos[2].Id, NroBancas = 20, FechaTotalizacion = DateTime.UtcNow },
|
||||
new() { EleccionId = eleccionNacionalId, CategoriaId = 2, AmbitoGeograficoId = provincia.Id, AgrupacionPoliticaId = partidos[3].Id, NroBancas = 10, FechaTotalizacion = DateTime.UtcNow },
|
||||
new() { EleccionId = eleccionNacionalId, CategoriaId = 2, AmbitoGeograficoId = provincia.Id, AgrupacionPoliticaId = partidos[4].Id, NroBancas = 7, FechaTotalizacion = DateTime.UtcNow },
|
||||
|
||||
// -- SENADORES (Se renuevan 24) --
|
||||
new() { EleccionId = eleccionNacionalId, CategoriaId = 1, AmbitoGeograficoId = provincia.Id, AgrupacionPoliticaId = partidos[0].Id, NroBancas = 10, FechaTotalizacion = DateTime.UtcNow },
|
||||
new() { EleccionId = eleccionNacionalId, CategoriaId = 1, AmbitoGeograficoId = provincia.Id, AgrupacionPoliticaId = partidos[1].Id, NroBancas = 8, FechaTotalizacion = DateTime.UtcNow },
|
||||
new() { EleccionId = eleccionNacionalId, CategoriaId = 1, AmbitoGeograficoId = provincia.Id, AgrupacionPoliticaId = partidos[2].Id, NroBancas = 4, FechaTotalizacion = DateTime.UtcNow },
|
||||
new() { EleccionId = eleccionNacionalId, CategoriaId = 1, AmbitoGeograficoId = provincia.Id, AgrupacionPoliticaId = partidos[3].Id, NroBancas = 2, FechaTotalizacion = DateTime.UtcNow },
|
||||
};
|
||||
await context.ProyeccionesBancas.AddRangeAsync(proyecciones);
|
||||
await context.SaveChangesAsync();
|
||||
Console.WriteLine("--> Seeded Proyecciones de Bancas para la Elección Nacional.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +314,10 @@ using (var scope = app.Services.CreateScope())
|
||||
{ "Worker_Resultados_Activado", "false" },
|
||||
{ "Worker_Bajas_Activado", "false" },
|
||||
{ "Worker_Prioridad", "Resultados" },
|
||||
{ "Logging_Level", "Information" }
|
||||
{ "Logging_Level", "Information" },
|
||||
{ "PresidenciaDiputadosNacional", "" },
|
||||
{ "PresidenciaDiputadosNacional_TipoBanca", "ganada" },
|
||||
{ "PresidenciaSenadoNacional_TipoBanca", "ganada" }
|
||||
};
|
||||
|
||||
foreach (var config in defaultConfiguraciones)
|
||||
@@ -230,7 +347,7 @@ using (var scope = app.Services.CreateScope())
|
||||
|
||||
var eleccionNacional = await context.Elecciones.FindAsync(eleccionNacionalId) ?? new Eleccion { Id = eleccionNacionalId, Nombre = "Elecciones Nacionales 2025", Nivel = "Nacional", DistritoId = "00", Fecha = new DateOnly(2025, 10, 26) };
|
||||
if (!context.Elecciones.Local.Any(e => e.Id == eleccionNacionalId)) context.Elecciones.Add(eleccionNacional);
|
||||
|
||||
|
||||
var categoriaDiputadosNac = await context.CategoriasElectorales.FindAsync(2) ?? new CategoriaElectoral { Id = 2, Nombre = "DIPUTADOS NACIONALES", Orden = 3 };
|
||||
if (!context.CategoriasElectorales.Local.Any(c => c.Id == 2)) context.CategoriasElectorales.Add(categoriaDiputadosNac);
|
||||
await context.SaveChangesAsync();
|
||||
@@ -270,7 +387,8 @@ using (var scope = app.Services.CreateScope())
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
var todosLosPartidos = await context.AgrupacionesPoliticas.Take(5).ToListAsync();
|
||||
if (!todosLosPartidos.Any()) {
|
||||
if (!todosLosPartidos.Any())
|
||||
{
|
||||
logger.LogWarning("--> No hay partidos, no se pueden generar votos.");
|
||||
return;
|
||||
}
|
||||
@@ -278,7 +396,7 @@ using (var scope = app.Services.CreateScope())
|
||||
var nuevosResultados = new List<ResultadoVoto>();
|
||||
var nuevosEstados = new List<EstadoRecuentoGeneral>();
|
||||
var rand = new Random();
|
||||
|
||||
|
||||
long totalVotosNacional = 0;
|
||||
int totalMesasNacional = 0;
|
||||
int totalMesasEscrutadasNacional = 0;
|
||||
@@ -287,9 +405,9 @@ using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var municipiosDeProvincia = await context.AmbitosGeograficos.AsNoTracking().Where(a => a.NivelId == 30 && a.DistritoId == provincia.DistritoId).ToListAsync();
|
||||
if (!municipiosDeProvincia.Any()) continue;
|
||||
|
||||
|
||||
long totalVotosProvincia = 0;
|
||||
|
||||
|
||||
int partidoIndex = rand.Next(todosLosPartidos.Count);
|
||||
foreach (var municipio in municipiosDeProvincia)
|
||||
{
|
||||
@@ -299,7 +417,8 @@ using (var scope = app.Services.CreateScope())
|
||||
totalVotosProvincia += votosGanador;
|
||||
|
||||
var otrosPartidos = todosLosPartidos.Where(p => p.Id != partidoGanador.Id).OrderBy(p => rand.Next()).Take(rand.Next(3, todosLosPartidos.Count));
|
||||
foreach (var competidor in otrosPartidos) {
|
||||
foreach (var competidor in otrosPartidos)
|
||||
{
|
||||
var votosCompetidor = rand.Next(1000, 24000);
|
||||
nuevosResultados.Add(new ResultadoVoto { EleccionId = eleccionNacionalId, AmbitoGeograficoId = municipio.Id, CategoriaId = categoriaDiputadosNac.Id, AgrupacionPoliticaId = competidor.Id, CantidadVotos = votosCompetidor });
|
||||
totalVotosProvincia += votosCompetidor;
|
||||
@@ -312,8 +431,11 @@ using (var scope = app.Services.CreateScope())
|
||||
var cantidadElectoresProvincia = mesasEsperadasProvincia * 350;
|
||||
var participacionProvincia = (decimal)(rand.Next(65, 85) / 100.0);
|
||||
|
||||
nuevosEstados.Add(new EstadoRecuentoGeneral {
|
||||
EleccionId = eleccionNacionalId, AmbitoGeograficoId = provincia.Id, CategoriaId = categoriaDiputadosNac.Id,
|
||||
nuevosEstados.Add(new EstadoRecuentoGeneral
|
||||
{
|
||||
EleccionId = eleccionNacionalId,
|
||||
AmbitoGeograficoId = provincia.Id,
|
||||
CategoriaId = categoriaDiputadosNac.Id,
|
||||
FechaTotalizacion = DateTime.UtcNow,
|
||||
MesasEsperadas = mesasEsperadasProvincia,
|
||||
MesasTotalizadas = mesasTotalizadasProvincia,
|
||||
@@ -322,7 +444,7 @@ using (var scope = app.Services.CreateScope())
|
||||
CantidadVotantes = (int)(cantidadElectoresProvincia * participacionProvincia),
|
||||
ParticipacionPorcentaje = participacionProvincia * 100
|
||||
});
|
||||
|
||||
|
||||
totalVotosNacional += totalVotosProvincia;
|
||||
totalMesasNacional += mesasEsperadasProvincia;
|
||||
totalMesasEscrutadasNacional += mesasTotalizadasProvincia;
|
||||
@@ -330,14 +452,18 @@ using (var scope = app.Services.CreateScope())
|
||||
|
||||
// --- LÓGICA DE DATOS DE RECUENTO A NIVEL NACIONAL ---
|
||||
var ambitoNacional = await context.AmbitosGeograficos.AsNoTracking().FirstOrDefaultAsync(a => a.NivelId == 0);
|
||||
if (ambitoNacional == null) {
|
||||
if (ambitoNacional == null)
|
||||
{
|
||||
ambitoNacional = new AmbitoGeografico { Nombre = "Nacional", NivelId = 0, DistritoId = "00" };
|
||||
context.AmbitosGeograficos.Add(ambitoNacional);
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
var participacionNacional = (decimal)(rand.Next(70, 88) / 100.0);
|
||||
nuevosEstados.Add(new EstadoRecuentoGeneral {
|
||||
EleccionId = eleccionNacionalId, AmbitoGeograficoId = ambitoNacional.Id, CategoriaId = categoriaDiputadosNac.Id,
|
||||
nuevosEstados.Add(new EstadoRecuentoGeneral
|
||||
{
|
||||
EleccionId = eleccionNacionalId,
|
||||
AmbitoGeograficoId = ambitoNacional.Id,
|
||||
CategoriaId = categoriaDiputadosNac.Id,
|
||||
FechaTotalizacion = DateTime.UtcNow,
|
||||
MesasEsperadas = totalMesasNacional,
|
||||
MesasTotalizadas = totalMesasEscrutadasNacional,
|
||||
@@ -347,17 +473,56 @@ using (var scope = app.Services.CreateScope())
|
||||
ParticipacionPorcentaje = participacionNacional * 100
|
||||
});
|
||||
|
||||
if (nuevosResultados.Any()) {
|
||||
if (nuevosResultados.Any())
|
||||
{
|
||||
await context.ResultadosVotos.AddRangeAsync(nuevosResultados);
|
||||
await context.EstadosRecuentosGenerales.AddRangeAsync(nuevosEstados);
|
||||
await context.SaveChangesAsync();
|
||||
logger.LogInformation("--> Se generaron {Votos} registros de votos y {Estados} de estados de recuento.", nuevosResultados.Count, nuevosEstados.Count);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogWarning("--> No se generaron datos de simulación.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Seeder para Bancas Previas (Composición Nacional 2025) ---
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var services = scope.ServiceProvider;
|
||||
var context = services.GetRequiredService<EleccionesDbContext>();
|
||||
|
||||
const int eleccionNacionalId = 2;
|
||||
|
||||
if (!context.BancasPrevias.Any(b => b.EleccionId == eleccionNacionalId))
|
||||
{
|
||||
var partidos = await context.AgrupacionesPoliticas.Take(5).ToListAsync();
|
||||
if (partidos.Count >= 5)
|
||||
{
|
||||
var bancasPrevias = new List<BancaPrevia>
|
||||
{
|
||||
// -- DIPUTADOS (Total: 257, se renuevan 127, quedan 130) --
|
||||
new() { EleccionId = eleccionNacionalId, Camara = TipoCamara.Diputados, AgrupacionPoliticaId = partidos[0].Id, Cantidad = 40 },
|
||||
new() { EleccionId = eleccionNacionalId, Camara = TipoCamara.Diputados, AgrupacionPoliticaId = partidos[1].Id, Cantidad = 35 },
|
||||
new() { EleccionId = eleccionNacionalId, Camara = TipoCamara.Diputados, AgrupacionPoliticaId = partidos[2].Id, Cantidad = 30 },
|
||||
new() { EleccionId = eleccionNacionalId, Camara = TipoCamara.Diputados, AgrupacionPoliticaId = partidos[3].Id, Cantidad = 15 },
|
||||
new() { EleccionId = eleccionNacionalId, Camara = TipoCamara.Diputados, AgrupacionPoliticaId = partidos[4].Id, Cantidad = 10 },
|
||||
|
||||
// -- SENADORES (Total: 72, se renuevan 24, quedan 48) --
|
||||
new() { EleccionId = eleccionNacionalId, Camara = TipoCamara.Senadores, AgrupacionPoliticaId = partidos[0].Id, Cantidad = 18 },
|
||||
new() { EleccionId = eleccionNacionalId, Camara = TipoCamara.Senadores, AgrupacionPoliticaId = partidos[1].Id, Cantidad = 15 },
|
||||
new() { EleccionId = eleccionNacionalId, Camara = TipoCamara.Senadores, AgrupacionPoliticaId = partidos[2].Id, Cantidad = 8 },
|
||||
new() { EleccionId = eleccionNacionalId, Camara = TipoCamara.Senadores, AgrupacionPoliticaId = partidos[3].Id, Cantidad = 4 },
|
||||
new() { EleccionId = eleccionNacionalId, Camara = TipoCamara.Senadores, AgrupacionPoliticaId = partidos[4].Id, Cantidad = 3 },
|
||||
};
|
||||
await context.BancasPrevias.AddRangeAsync(bancasPrevias);
|
||||
await context.SaveChangesAsync();
|
||||
Console.WriteLine("--> Seeded Bancas Previas para la Elección Nacional.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Configurar el pipeline de peticiones HTTP.
|
||||
// Añadimos el logging de peticiones de Serilog aquí.
|
||||
app.UseSerilogRequestLogging();
|
||||
|
||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Elecciones.Api")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+5a8bee52d57b0f215705f3a7efb654169f85a7ae")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+67634ae947197595f6f644f3a80a982dd3573dfb")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Elecciones.Api")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Elecciones.Api")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"GlobalPropertiesHash":"b5T/+ta4fUd8qpIzUTm3KyEwAYYUsU5ASo+CSFM3ByE=","FingerprintPatternsHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["TyIJk/eQMWjmB5LsDE\u002BZIJC9P9ciVxd7bnzRiTZsGt4=","t631p0kaOa0gMRIcaPzz1ZVPZ1kuq4pq4kYPWQgoPcM=","PA/Beu9jJpOBY5r5Y1CiSyqrARA2j7LHeWYUnEZpQO8=","E2ODTAlJxzsXY1iP1eB/02NIUK\u002BnQveGlWAOHY1cpgA=","cdgbHR/E4DJsddPc\u002BTpzoUMOVNaFJZm33Pw7AxU9Ees=","4r4JGR4hS5m4rsLfuCSZxzrknTBxKFkLQDXc\u002B2KbqTU=","yVoZ4UnBcSOapsJIi046hnn7ylD3jAcEBUxQ\u002Brkvj/4=","/GfbpJthEWmsuz0uFx1QLHM7gyM1wLLeQgAIl4SzUD4=","i5\u002B5LcfxQD8meRAkQbVf4wMvjxSE4\u002BjCd2/FdPtMpms=","AvSkxVPIg0GjnB1RJ4hDNyo9p9GONrzDs8uVuixH\u002BOE=","IgT9pOgRnK37qfILj2QcjFoBZ180HMt\u002BScgje2iYOo4=","ezUlOMzNZmyKDIe1wwXqvX\u002BvhwfB992xNVts7r2zcTc=","y2BV4WpkQuLfqQhfOQBtmuzh940c3s4LAopGKfztfTE=","lHTUEsMkDu8nqXtfTwl7FRfgocyyc7RI5O/edTHN1\u002B0=","A7nz7qgOtQ1CwZZLvNnr0b5QZB3fTi3y4i6y7rBIcxQ=","znnuRi2tsk7AACuYo4WSgj7NcLriG4PKVaF4L35SvDk=","GelE32odx/vTului267wqi6zL3abBnF9yvwC2Q66LoM=","TEsXImnzxFKTIq2f5fiDu7i6Ar/cbecW5MZ3z8Wb/a4=","5WogJu\u002BUPlF\u002BE5mq/ILtDXpVwqwmhHtsEB13nmT5JJk=","dcHQRkttjMjo2dvhL7hA9t4Pg\u002B7OnjZpkFmakT4QR9U=","Of8nTYw5l\u002BgiAJo7z6XYIntG2tUtCFcILzHbTiiXn\u002Bw=","PDy\u002BTiayvNAoXXBEgwC/kCojpgOOMI6RQOIoSXs3LJc=","ePXrkee3hv3wHUr8S7aYmRVvXUTxQf76zApKGv3/l3o=","DXx5dQywLo3UsY2zQaUG\u002BbW4ObiYbybxPBWxeJD2bhk=","muVh5sjH3sgdvuz4TbuTwTggX1uDnsWXgoosMKST/r4=","nrP5gSIA5vzgp8v12CAOr943QYLxU4Til6oiCcWSNI8=","yMd45U9BK07I3b3fBQ627PWTYyZ2ZjrmFc5VD\u002BQVx1Q=","xKskvcoJU0RVRN1a5dRqKRM7IP5vmmbraUaPFYjhnCc=","p7BjQw7aSZjfOCqmKm7/kPO9qegEQZBfirMjlOx/I1I=","MI0hVVLYavEhzHq/Z1UbajfrxanA1aET19aOH8G2ImI=","2dY8CqW9fAY8yN0foa\u002BZp2gc0RfPoPmB/tKSj1QoTw0=","79rfGLH4UjfTPvc//\u002BZjnBqdz585pUtYZ0/hwE2iEic=","PUqgvMdfTQkF5lpBVtHv2teQLV5WaEH0xMKTmINe2YQ=","\u002BFI0b4ppdxel/pby/y/xKImHrtdxo2g83OhskdREyIg=","ayv780bSyYJGn9z2hycOzUCHGRbnvrzG/wr0RB8XoSg=","P8JRhYPpULTLMAydvl3Ky\u002B92/tYDIjui0l66En4aXuQ=","WbNXPR1x3J5zRGe6yPRR\u002BWmWo3I/jnjzOyd\u002BJP8MhMI="],"CachedAssets":{},"CachedCopyCandidates":{}}
|
||||
{"GlobalPropertiesHash":"b5T/+ta4fUd8qpIzUTm3KyEwAYYUsU5ASo+CSFM3ByE=","FingerprintPatternsHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["TyIJk/eQMWjmB5LsDE\u002BZIJC9P9ciVxd7bnzRiTZsGt4=","t631p0kaOa0gMRIcaPzz1ZVPZ1kuq4pq4kYPWQgoPcM=","PA/Beu9jJpOBY5r5Y1CiSyqrARA2j7LHeWYUnEZpQO8=","E2ODTAlJxzsXY1iP1eB/02NIUK\u002BnQveGlWAOHY1cpgA=","i5\u002B5LcfxQD8meRAkQbVf4wMvjxSE4\u002BjCd2/FdPtMpms=","AvSkxVPIg0GjnB1RJ4hDNyo9p9GONrzDs8uVuixH\u002BOE=","IgT9pOgRnK37qfILj2QcjFoBZ180HMt\u002BScgje2iYOo4=","ezUlOMzNZmyKDIe1wwXqvX\u002BvhwfB992xNVts7r2zcTc=","y2BV4WpkQuLfqQhfOQBtmuzh940c3s4LAopGKfztfTE=","lHTUEsMkDu8nqXtfTwl7FRfgocyyc7RI5O/edTHN1\u002B0=","A7nz7qgOtQ1CwZZLvNnr0b5QZB3fTi3y4i6y7rBIcxQ=","znnuRi2tsk7AACuYo4WSgj7NcLriG4PKVaF4L35SvDk=","GelE32odx/vTului267wqi6zL3abBnF9yvwC2Q66LoM=","TEsXImnzxFKTIq2f5fiDu7i6Ar/cbecW5MZ3z8Wb/a4=","5WogJu\u002BUPlF\u002BE5mq/ILtDXpVwqwmhHtsEB13nmT5JJk=","dcHQRkttjMjo2dvhL7hA9t4Pg\u002B7OnjZpkFmakT4QR9U=","Of8nTYw5l\u002BgiAJo7z6XYIntG2tUtCFcILzHbTiiXn\u002Bw=","PDy\u002BTiayvNAoXXBEgwC/kCojpgOOMI6RQOIoSXs3LJc=","ePXrkee3hv3wHUr8S7aYmRVvXUTxQf76zApKGv3/l3o=","DXx5dQywLo3UsY2zQaUG\u002BbW4ObiYbybxPBWxeJD2bhk=","muVh5sjH3sgdvuz4TbuTwTggX1uDnsWXgoosMKST/r4=","nrP5gSIA5vzgp8v12CAOr943QYLxU4Til6oiCcWSNI8=","yMd45U9BK07I3b3fBQ627PWTYyZ2ZjrmFc5VD\u002BQVx1Q=","xKskvcoJU0RVRN1a5dRqKRM7IP5vmmbraUaPFYjhnCc=","p7BjQw7aSZjfOCqmKm7/kPO9qegEQZBfirMjlOx/I1I=","MI0hVVLYavEhzHq/Z1UbajfrxanA1aET19aOH8G2ImI=","2dY8CqW9fAY8yN0foa\u002BZp2gc0RfPoPmB/tKSj1QoTw0=","79rfGLH4UjfTPvc//\u002BZjnBqdz585pUtYZ0/hwE2iEic=","PUqgvMdfTQkF5lpBVtHv2teQLV5WaEH0xMKTmINe2YQ=","\u002BFI0b4ppdxel/pby/y/xKImHrtdxo2g83OhskdREyIg=","jEESu6\u002BhbDvNMjLt/6OufuK\u002B9cHmzx\u002BTCIn4fWa9nSc=","UaCPJEvR4nVxxGCB5CUnRlJiw4drDW3Q3Nss\u002Bya2cv4=","ZqF13CT3rok/Gzl\u002BMsw3q9X1nf65bwEVD670efE3k\u002Bk=","gH3W7phPzBCY1DAVn4YnP4SA8Uaq73TpctS0yFSvzNM=","0dvJZBTDvT8AWA99AJa8lh9rnQsEsujRTFe1QDxskcw=","P8JRhYPpULTLMAydvl3Ky\u002B92/tYDIjui0l66En4aXuQ=","amEOUyqq4sgg/zUP6A7nQMqSHcl7G5zl2HvyHRlhDvU="],"CachedAssets":{},"CachedCopyCandidates":{}}
|
||||
@@ -1 +1 @@
|
||||
{"GlobalPropertiesHash":"tJTBjV/i0Ihkc6XuOu69wxL8PBac9c9Kak6srMso4pU=","FingerprintPatternsHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["TyIJk/eQMWjmB5LsDE\u002BZIJC9P9ciVxd7bnzRiTZsGt4=","t631p0kaOa0gMRIcaPzz1ZVPZ1kuq4pq4kYPWQgoPcM=","PA/Beu9jJpOBY5r5Y1CiSyqrARA2j7LHeWYUnEZpQO8=","E2ODTAlJxzsXY1iP1eB/02NIUK\u002BnQveGlWAOHY1cpgA=","cdgbHR/E4DJsddPc\u002BTpzoUMOVNaFJZm33Pw7AxU9Ees=","4r4JGR4hS5m4rsLfuCSZxzrknTBxKFkLQDXc\u002B2KbqTU=","yVoZ4UnBcSOapsJIi046hnn7ylD3jAcEBUxQ\u002Brkvj/4=","/GfbpJthEWmsuz0uFx1QLHM7gyM1wLLeQgAIl4SzUD4=","i5\u002B5LcfxQD8meRAkQbVf4wMvjxSE4\u002BjCd2/FdPtMpms=","AvSkxVPIg0GjnB1RJ4hDNyo9p9GONrzDs8uVuixH\u002BOE=","IgT9pOgRnK37qfILj2QcjFoBZ180HMt\u002BScgje2iYOo4=","ezUlOMzNZmyKDIe1wwXqvX\u002BvhwfB992xNVts7r2zcTc=","y2BV4WpkQuLfqQhfOQBtmuzh940c3s4LAopGKfztfTE=","lHTUEsMkDu8nqXtfTwl7FRfgocyyc7RI5O/edTHN1\u002B0=","A7nz7qgOtQ1CwZZLvNnr0b5QZB3fTi3y4i6y7rBIcxQ=","znnuRi2tsk7AACuYo4WSgj7NcLriG4PKVaF4L35SvDk=","GelE32odx/vTului267wqi6zL3abBnF9yvwC2Q66LoM=","TEsXImnzxFKTIq2f5fiDu7i6Ar/cbecW5MZ3z8Wb/a4=","5WogJu\u002BUPlF\u002BE5mq/ILtDXpVwqwmhHtsEB13nmT5JJk=","dcHQRkttjMjo2dvhL7hA9t4Pg\u002B7OnjZpkFmakT4QR9U=","Of8nTYw5l\u002BgiAJo7z6XYIntG2tUtCFcILzHbTiiXn\u002Bw=","PDy\u002BTiayvNAoXXBEgwC/kCojpgOOMI6RQOIoSXs3LJc=","ePXrkee3hv3wHUr8S7aYmRVvXUTxQf76zApKGv3/l3o=","DXx5dQywLo3UsY2zQaUG\u002BbW4ObiYbybxPBWxeJD2bhk=","muVh5sjH3sgdvuz4TbuTwTggX1uDnsWXgoosMKST/r4=","nrP5gSIA5vzgp8v12CAOr943QYLxU4Til6oiCcWSNI8=","yMd45U9BK07I3b3fBQ627PWTYyZ2ZjrmFc5VD\u002BQVx1Q=","xKskvcoJU0RVRN1a5dRqKRM7IP5vmmbraUaPFYjhnCc=","p7BjQw7aSZjfOCqmKm7/kPO9qegEQZBfirMjlOx/I1I=","MI0hVVLYavEhzHq/Z1UbajfrxanA1aET19aOH8G2ImI=","2dY8CqW9fAY8yN0foa\u002BZp2gc0RfPoPmB/tKSj1QoTw0=","79rfGLH4UjfTPvc//\u002BZjnBqdz585pUtYZ0/hwE2iEic=","PUqgvMdfTQkF5lpBVtHv2teQLV5WaEH0xMKTmINe2YQ=","\u002BFI0b4ppdxel/pby/y/xKImHrtdxo2g83OhskdREyIg=","ayv780bSyYJGn9z2hycOzUCHGRbnvrzG/wr0RB8XoSg=","P8JRhYPpULTLMAydvl3Ky\u002B92/tYDIjui0l66En4aXuQ=","WbNXPR1x3J5zRGe6yPRR\u002BWmWo3I/jnjzOyd\u002BJP8MhMI="],"CachedAssets":{},"CachedCopyCandidates":{}}
|
||||
{"GlobalPropertiesHash":"tJTBjV/i0Ihkc6XuOu69wxL8PBac9c9Kak6srMso4pU=","FingerprintPatternsHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["TyIJk/eQMWjmB5LsDE\u002BZIJC9P9ciVxd7bnzRiTZsGt4=","t631p0kaOa0gMRIcaPzz1ZVPZ1kuq4pq4kYPWQgoPcM=","PA/Beu9jJpOBY5r5Y1CiSyqrARA2j7LHeWYUnEZpQO8=","E2ODTAlJxzsXY1iP1eB/02NIUK\u002BnQveGlWAOHY1cpgA=","i5\u002B5LcfxQD8meRAkQbVf4wMvjxSE4\u002BjCd2/FdPtMpms=","AvSkxVPIg0GjnB1RJ4hDNyo9p9GONrzDs8uVuixH\u002BOE=","IgT9pOgRnK37qfILj2QcjFoBZ180HMt\u002BScgje2iYOo4=","ezUlOMzNZmyKDIe1wwXqvX\u002BvhwfB992xNVts7r2zcTc=","y2BV4WpkQuLfqQhfOQBtmuzh940c3s4LAopGKfztfTE=","lHTUEsMkDu8nqXtfTwl7FRfgocyyc7RI5O/edTHN1\u002B0=","A7nz7qgOtQ1CwZZLvNnr0b5QZB3fTi3y4i6y7rBIcxQ=","znnuRi2tsk7AACuYo4WSgj7NcLriG4PKVaF4L35SvDk=","GelE32odx/vTului267wqi6zL3abBnF9yvwC2Q66LoM=","TEsXImnzxFKTIq2f5fiDu7i6Ar/cbecW5MZ3z8Wb/a4=","5WogJu\u002BUPlF\u002BE5mq/ILtDXpVwqwmhHtsEB13nmT5JJk=","dcHQRkttjMjo2dvhL7hA9t4Pg\u002B7OnjZpkFmakT4QR9U=","Of8nTYw5l\u002BgiAJo7z6XYIntG2tUtCFcILzHbTiiXn\u002Bw=","PDy\u002BTiayvNAoXXBEgwC/kCojpgOOMI6RQOIoSXs3LJc=","ePXrkee3hv3wHUr8S7aYmRVvXUTxQf76zApKGv3/l3o=","DXx5dQywLo3UsY2zQaUG\u002BbW4ObiYbybxPBWxeJD2bhk=","muVh5sjH3sgdvuz4TbuTwTggX1uDnsWXgoosMKST/r4=","nrP5gSIA5vzgp8v12CAOr943QYLxU4Til6oiCcWSNI8=","yMd45U9BK07I3b3fBQ627PWTYyZ2ZjrmFc5VD\u002BQVx1Q=","xKskvcoJU0RVRN1a5dRqKRM7IP5vmmbraUaPFYjhnCc=","p7BjQw7aSZjfOCqmKm7/kPO9qegEQZBfirMjlOx/I1I=","MI0hVVLYavEhzHq/Z1UbajfrxanA1aET19aOH8G2ImI=","2dY8CqW9fAY8yN0foa\u002BZp2gc0RfPoPmB/tKSj1QoTw0=","79rfGLH4UjfTPvc//\u002BZjnBqdz585pUtYZ0/hwE2iEic=","PUqgvMdfTQkF5lpBVtHv2teQLV5WaEH0xMKTmINe2YQ=","\u002BFI0b4ppdxel/pby/y/xKImHrtdxo2g83OhskdREyIg=","jEESu6\u002BhbDvNMjLt/6OufuK\u002B9cHmzx\u002BTCIn4fWa9nSc=","UaCPJEvR4nVxxGCB5CUnRlJiw4drDW3Q3Nss\u002Bya2cv4=","ZqF13CT3rok/Gzl\u002BMsw3q9X1nf65bwEVD670efE3k\u002Bk=","gH3W7phPzBCY1DAVn4YnP4SA8Uaq73TpctS0yFSvzNM=","0dvJZBTDvT8AWA99AJa8lh9rnQsEsujRTFe1QDxskcw=","P8JRhYPpULTLMAydvl3Ky\u002B92/tYDIjui0l66En4aXuQ=","amEOUyqq4sgg/zUP6A7nQMqSHcl7G5zl2HvyHRlhDvU="],"CachedAssets":{},"CachedCopyCandidates":{}}
|
||||
@@ -0,0 +1,22 @@
|
||||
// src/Elecciones.Core/DTOs/ApiResponses/ResumenProvinciaDto.cs
|
||||
namespace Elecciones.Core.DTOs.ApiResponses;
|
||||
|
||||
public class ResultadoCandidatoDto
|
||||
{
|
||||
public string AgrupacionId { get; set; } = string.Empty;
|
||||
public string? NombreCandidato { get; set; }
|
||||
public string NombreAgrupacion { get; set; } = null!;
|
||||
public string? FotoUrl { get; set; }
|
||||
public string? Color { get; set; }
|
||||
public decimal Porcentaje { get; set; }
|
||||
public long Votos { get; set; }
|
||||
public int BancasObtenidas { get; set; }
|
||||
}
|
||||
|
||||
public class ResumenProvinciaDto
|
||||
{
|
||||
public string ProvinciaId { get; set; } = null!; // Corresponde al DistritoId
|
||||
public string ProvinciaNombre { get; set; } = null!;
|
||||
public EstadoRecuentoDto? EstadoRecuento { get; set; }
|
||||
public List<ResultadoCandidatoDto> Resultados { get; set; } = new();
|
||||
}
|
||||
@@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Elecciones.Core")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+5a8bee52d57b0f215705f3a7efb654169f85a7ae")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+67634ae947197595f6f644f3a80a982dd3573dfb")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Elecciones.Core")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Elecciones.Core")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -22,6 +22,7 @@ public class EleccionesDbContext(DbContextOptions<EleccionesDbContext> options)
|
||||
public DbSet<LogoAgrupacionCategoria> LogosAgrupacionesCategorias { get; set; }
|
||||
public DbSet<CandidatoOverride> CandidatosOverrides { get; set; }
|
||||
public DbSet<Eleccion> Elecciones { get; set; }
|
||||
public DbSet<BancaPrevia> BancasPrevias { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
@@ -90,5 +91,10 @@ public class EleccionesDbContext(DbContextOptions<EleccionesDbContext> options)
|
||||
entity.HasIndex(c => new { c.AgrupacionPoliticaId, c.CategoriaId, c.AmbitoGeograficoId })
|
||||
.IsUnique();
|
||||
});
|
||||
modelBuilder.Entity<BancaPrevia>(entity =>
|
||||
{
|
||||
entity.Property(e => e.AgrupacionPoliticaId)
|
||||
.UseCollation("Modern_Spanish_CI_AS");
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,14 @@ public class AgrupacionPolitica
|
||||
public string IdTelegrama { get; set; } = null!;
|
||||
[Required]
|
||||
public string Nombre { get; set; } = null!;
|
||||
public string? NombreCorto { get; set; } // Para leyendas y gráficos
|
||||
public string? Color { get; set; } // Código hexadecimal, ej: "#1f77b4"
|
||||
public string? NombreCorto { get; set; }
|
||||
public string? Color { get; set; }
|
||||
|
||||
// --- Campos para Provinciales ---
|
||||
public int? OrdenDiputados { get; set; }
|
||||
public int? OrdenSenadores { get; set; }
|
||||
|
||||
// --- Campos para Nacionales ---
|
||||
public int? OrdenDiputadosNacionales { get; set; }
|
||||
public int? OrdenSenadoresNacionales { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// src/Elecciones.Database/Entities/BancaPrevia.cs
|
||||
using Elecciones.Core.Enums;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Elecciones.Database.Entities;
|
||||
|
||||
public class BancaPrevia
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int EleccionId { get; set; }
|
||||
|
||||
[Required]
|
||||
public TipoCamara Camara { get; set; }
|
||||
|
||||
[Required]
|
||||
public string AgrupacionPoliticaId { get; set; } = null!;
|
||||
|
||||
[ForeignKey("AgrupacionPoliticaId")]
|
||||
public AgrupacionPolitica AgrupacionPolitica { get; set; } = null!;
|
||||
|
||||
// Cantidad de bancas que el partido retiene (no están en juego)
|
||||
[Required]
|
||||
public int Cantidad { get; set; }
|
||||
}
|
||||
@@ -7,6 +7,7 @@ namespace Elecciones.Database.Entities;
|
||||
public class EstadoRecuentoGeneral
|
||||
{
|
||||
public int AmbitoGeograficoId { get; set; }
|
||||
public AmbitoGeografico AmbitoGeografico { get; set; } = null!;
|
||||
public int CategoriaId { get; set; }
|
||||
public DateTime FechaTotalizacion { get; set; }
|
||||
public int MesasEsperadas { get; set; }
|
||||
|
||||
715
Elecciones-Web/src/Elecciones.Database/Migrations/20250922213437_AddBancasPreviasTable.Designer.cs
generated
Normal file
715
Elecciones-Web/src/Elecciones.Database/Migrations/20250922213437_AddBancasPreviasTable.Designer.cs
generated
Normal file
@@ -0,0 +1,715 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Elecciones.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Elecciones.Database.Migrations
|
||||
{
|
||||
[DbContext(typeof(EleccionesDbContext))]
|
||||
[Migration("20250922213437_AddBancasPreviasTable")]
|
||||
partial class AddBancasPreviasTable
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.UseCollation("Modern_Spanish_CI_AS")
|
||||
.HasAnnotation("ProductVersion", "9.0.8")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
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)");
|
||||
|
||||
b.Property<DateOnly>("Fecha")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<string>("Nivel")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Nombre")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Elecciones");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.AdminUser", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PasswordSalt")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("AdminUsers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.AgrupacionPolitica", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("Color")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("IdTelegrama")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Nombre")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("NombreCorto")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int?>("OrdenDiputados")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("OrdenSenadores")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("AgrupacionesPoliticas");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.AmbitoGeografico", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("CircuitoId")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("DistritoId")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("EstablecimientoId")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MesaId")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MunicipioId")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("NivelId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Nombre")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("SeccionId")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("SeccionProvincialId")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
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")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AgrupacionPoliticaId")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int>("Camara")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("NumeroBanca")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AgrupacionPoliticaId");
|
||||
|
||||
b.ToTable("Bancadas");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.CandidatoOverride", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AgrupacionPoliticaId")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int?>("AmbitoGeograficoId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CategoriaId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("NombreCandidato")
|
||||
.IsRequired()
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("nvarchar(255)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AmbitoGeograficoId");
|
||||
|
||||
b.HasIndex("CategoriaId");
|
||||
|
||||
b.HasIndex("AgrupacionPoliticaId", "CategoriaId", "AmbitoGeograficoId")
|
||||
.IsUnique()
|
||||
.HasFilter("[AmbitoGeograficoId] IS NOT NULL");
|
||||
|
||||
b.ToTable("CandidatosOverrides");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.CategoriaElectoral", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Nombre")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Orden")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("CategoriasElectorales");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.Configuracion", b =>
|
||||
{
|
||||
b.Property<string>("Clave")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("Valor")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.HasKey("Clave");
|
||||
|
||||
b.ToTable("Configuraciones");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.EstadoRecuento", b =>
|
||||
{
|
||||
b.Property<int>("AmbitoGeograficoId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CategoriaId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CantidadElectores")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CantidadVotantes")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("FechaTotalizacion")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("MesasEsperadas")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MesasTotalizadas")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("MesasTotalizadasPorcentaje")
|
||||
.HasPrecision(5, 2)
|
||||
.HasColumnType("decimal(5,2)");
|
||||
|
||||
b.Property<decimal>("ParticipacionPorcentaje")
|
||||
.HasPrecision(5, 2)
|
||||
.HasColumnType("decimal(5,2)");
|
||||
|
||||
b.Property<long>("VotosEnBlanco")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<decimal>("VotosEnBlancoPorcentaje")
|
||||
.HasPrecision(18, 4)
|
||||
.HasColumnType("decimal(18,4)");
|
||||
|
||||
b.Property<long>("VotosNulos")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<decimal>("VotosNulosPorcentaje")
|
||||
.HasPrecision(18, 4)
|
||||
.HasColumnType("decimal(18,4)");
|
||||
|
||||
b.Property<long>("VotosRecurridos")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<decimal>("VotosRecurridosPorcentaje")
|
||||
.HasPrecision(18, 4)
|
||||
.HasColumnType("decimal(18,4)");
|
||||
|
||||
b.HasKey("AmbitoGeograficoId", "CategoriaId");
|
||||
|
||||
b.ToTable("EstadosRecuentos");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.EstadoRecuentoGeneral", b =>
|
||||
{
|
||||
b.Property<int>("AmbitoGeograficoId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CategoriaId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CantidadElectores")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CantidadVotantes")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("FechaTotalizacion")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("MesasEsperadas")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MesasTotalizadas")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("MesasTotalizadasPorcentaje")
|
||||
.HasPrecision(5, 2)
|
||||
.HasColumnType("decimal(5,2)");
|
||||
|
||||
b.Property<decimal>("ParticipacionPorcentaje")
|
||||
.HasPrecision(5, 2)
|
||||
.HasColumnType("decimal(5,2)");
|
||||
|
||||
b.HasKey("AmbitoGeograficoId", "CategoriaId");
|
||||
|
||||
b.HasIndex("CategoriaId");
|
||||
|
||||
b.ToTable("EstadosRecuentosGenerales");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.LogoAgrupacionCategoria", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AgrupacionPoliticaId")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int?>("AmbitoGeograficoId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CategoriaId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("LogoUrl")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AgrupacionPoliticaId", "CategoriaId", "AmbitoGeograficoId")
|
||||
.IsUnique()
|
||||
.HasFilter("[AmbitoGeograficoId] IS NOT NULL");
|
||||
|
||||
b.ToTable("LogosAgrupacionesCategorias");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.OcupanteBanca", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BancadaId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("FotoUrl")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("NombreOcupante")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Periodo")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BancadaId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("OcupantesBancas");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.ProyeccionBanca", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AgrupacionPoliticaId")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int>("AmbitoGeograficoId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CategoriaId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("FechaTotalizacion")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("NroBancas")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AgrupacionPoliticaId");
|
||||
|
||||
b.HasIndex("AmbitoGeograficoId", "CategoriaId", "AgrupacionPoliticaId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("ProyeccionesBancas");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.ResultadoVoto", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<string>("AgrupacionPoliticaId")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int>("AmbitoGeograficoId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<long>("CantidadVotos")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("CategoriaId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("PorcentajeVotos")
|
||||
.HasPrecision(18, 4)
|
||||
.HasColumnType("decimal(18,4)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AgrupacionPoliticaId");
|
||||
|
||||
b.HasIndex("AmbitoGeograficoId", "CategoriaId", "AgrupacionPoliticaId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("ResultadosVotos");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.ResumenVoto", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AgrupacionPoliticaId")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int>("AmbitoGeograficoId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<long>("Votos")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<decimal>("VotosPorcentaje")
|
||||
.HasPrecision(5, 2)
|
||||
.HasColumnType("decimal(5,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AgrupacionPoliticaId");
|
||||
|
||||
b.ToTable("ResumenesVotos");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.Telegrama", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int>("AmbitoGeograficoId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ContenidoBase64")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("FechaEscaneo")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("FechaTotalizacion")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
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")
|
||||
.WithMany()
|
||||
.HasForeignKey("AgrupacionPoliticaId");
|
||||
|
||||
b.Navigation("AgrupacionPolitica");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.CandidatoOverride", b =>
|
||||
{
|
||||
b.HasOne("Elecciones.Database.Entities.AgrupacionPolitica", "AgrupacionPolitica")
|
||||
.WithMany()
|
||||
.HasForeignKey("AgrupacionPoliticaId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Elecciones.Database.Entities.AmbitoGeografico", "AmbitoGeografico")
|
||||
.WithMany()
|
||||
.HasForeignKey("AmbitoGeograficoId");
|
||||
|
||||
b.HasOne("Elecciones.Database.Entities.CategoriaElectoral", "CategoriaElectoral")
|
||||
.WithMany()
|
||||
.HasForeignKey("CategoriaId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("AgrupacionPolitica");
|
||||
|
||||
b.Navigation("AmbitoGeografico");
|
||||
|
||||
b.Navigation("CategoriaElectoral");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.EstadoRecuento", b =>
|
||||
{
|
||||
b.HasOne("Elecciones.Database.Entities.AmbitoGeografico", "AmbitoGeografico")
|
||||
.WithMany()
|
||||
.HasForeignKey("AmbitoGeograficoId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("AmbitoGeografico");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.EstadoRecuentoGeneral", b =>
|
||||
{
|
||||
b.HasOne("Elecciones.Database.Entities.CategoriaElectoral", "CategoriaElectoral")
|
||||
.WithMany()
|
||||
.HasForeignKey("CategoriaId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CategoriaElectoral");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.OcupanteBanca", b =>
|
||||
{
|
||||
b.HasOne("Elecciones.Database.Entities.Bancada", "Bancada")
|
||||
.WithOne("Ocupante")
|
||||
.HasForeignKey("Elecciones.Database.Entities.OcupanteBanca", "BancadaId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Bancada");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.ProyeccionBanca", b =>
|
||||
{
|
||||
b.HasOne("Elecciones.Database.Entities.AgrupacionPolitica", "AgrupacionPolitica")
|
||||
.WithMany()
|
||||
.HasForeignKey("AgrupacionPoliticaId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Elecciones.Database.Entities.AmbitoGeografico", "AmbitoGeografico")
|
||||
.WithMany()
|
||||
.HasForeignKey("AmbitoGeograficoId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("AgrupacionPolitica");
|
||||
|
||||
b.Navigation("AmbitoGeografico");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.ResultadoVoto", b =>
|
||||
{
|
||||
b.HasOne("Elecciones.Database.Entities.AgrupacionPolitica", "AgrupacionPolitica")
|
||||
.WithMany()
|
||||
.HasForeignKey("AgrupacionPoliticaId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Elecciones.Database.Entities.AmbitoGeografico", "AmbitoGeografico")
|
||||
.WithMany()
|
||||
.HasForeignKey("AmbitoGeograficoId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("AgrupacionPolitica");
|
||||
|
||||
b.Navigation("AmbitoGeografico");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.ResumenVoto", 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.Navigation("Ocupante");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,721 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Elecciones.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Elecciones.Database.Migrations
|
||||
{
|
||||
[DbContext(typeof(EleccionesDbContext))]
|
||||
[Migration("20250924000007_AddOrdenNacionalToAgrupaciones")]
|
||||
partial class AddOrdenNacionalToAgrupaciones
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.UseCollation("Modern_Spanish_CI_AS")
|
||||
.HasAnnotation("ProductVersion", "9.0.8")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
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)");
|
||||
|
||||
b.Property<DateOnly>("Fecha")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<string>("Nivel")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Nombre")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Elecciones");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.AdminUser", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PasswordSalt")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("AdminUsers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.AgrupacionPolitica", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("Color")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("IdTelegrama")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Nombre")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("NombreCorto")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
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");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.AmbitoGeografico", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("CircuitoId")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("DistritoId")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("EstablecimientoId")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MesaId")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MunicipioId")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("NivelId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Nombre")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("SeccionId")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("SeccionProvincialId")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
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")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AgrupacionPoliticaId")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int>("Camara")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("NumeroBanca")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AgrupacionPoliticaId");
|
||||
|
||||
b.ToTable("Bancadas");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.CandidatoOverride", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AgrupacionPoliticaId")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int?>("AmbitoGeograficoId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CategoriaId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("NombreCandidato")
|
||||
.IsRequired()
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("nvarchar(255)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AmbitoGeograficoId");
|
||||
|
||||
b.HasIndex("CategoriaId");
|
||||
|
||||
b.HasIndex("AgrupacionPoliticaId", "CategoriaId", "AmbitoGeograficoId")
|
||||
.IsUnique()
|
||||
.HasFilter("[AmbitoGeograficoId] IS NOT NULL");
|
||||
|
||||
b.ToTable("CandidatosOverrides");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.CategoriaElectoral", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Nombre")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Orden")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("CategoriasElectorales");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.Configuracion", b =>
|
||||
{
|
||||
b.Property<string>("Clave")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("Valor")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.HasKey("Clave");
|
||||
|
||||
b.ToTable("Configuraciones");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.EstadoRecuento", b =>
|
||||
{
|
||||
b.Property<int>("AmbitoGeograficoId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CategoriaId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CantidadElectores")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CantidadVotantes")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("FechaTotalizacion")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("MesasEsperadas")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MesasTotalizadas")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("MesasTotalizadasPorcentaje")
|
||||
.HasPrecision(5, 2)
|
||||
.HasColumnType("decimal(5,2)");
|
||||
|
||||
b.Property<decimal>("ParticipacionPorcentaje")
|
||||
.HasPrecision(5, 2)
|
||||
.HasColumnType("decimal(5,2)");
|
||||
|
||||
b.Property<long>("VotosEnBlanco")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<decimal>("VotosEnBlancoPorcentaje")
|
||||
.HasPrecision(18, 4)
|
||||
.HasColumnType("decimal(18,4)");
|
||||
|
||||
b.Property<long>("VotosNulos")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<decimal>("VotosNulosPorcentaje")
|
||||
.HasPrecision(18, 4)
|
||||
.HasColumnType("decimal(18,4)");
|
||||
|
||||
b.Property<long>("VotosRecurridos")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<decimal>("VotosRecurridosPorcentaje")
|
||||
.HasPrecision(18, 4)
|
||||
.HasColumnType("decimal(18,4)");
|
||||
|
||||
b.HasKey("AmbitoGeograficoId", "CategoriaId");
|
||||
|
||||
b.ToTable("EstadosRecuentos");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.EstadoRecuentoGeneral", b =>
|
||||
{
|
||||
b.Property<int>("AmbitoGeograficoId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CategoriaId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CantidadElectores")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CantidadVotantes")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("FechaTotalizacion")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("MesasEsperadas")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MesasTotalizadas")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("MesasTotalizadasPorcentaje")
|
||||
.HasPrecision(5, 2)
|
||||
.HasColumnType("decimal(5,2)");
|
||||
|
||||
b.Property<decimal>("ParticipacionPorcentaje")
|
||||
.HasPrecision(5, 2)
|
||||
.HasColumnType("decimal(5,2)");
|
||||
|
||||
b.HasKey("AmbitoGeograficoId", "CategoriaId");
|
||||
|
||||
b.HasIndex("CategoriaId");
|
||||
|
||||
b.ToTable("EstadosRecuentosGenerales");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.LogoAgrupacionCategoria", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AgrupacionPoliticaId")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int?>("AmbitoGeograficoId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CategoriaId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("LogoUrl")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AgrupacionPoliticaId", "CategoriaId", "AmbitoGeograficoId")
|
||||
.IsUnique()
|
||||
.HasFilter("[AmbitoGeograficoId] IS NOT NULL");
|
||||
|
||||
b.ToTable("LogosAgrupacionesCategorias");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.OcupanteBanca", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BancadaId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("FotoUrl")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("NombreOcupante")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Periodo")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BancadaId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("OcupantesBancas");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.ProyeccionBanca", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AgrupacionPoliticaId")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int>("AmbitoGeograficoId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CategoriaId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("FechaTotalizacion")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("NroBancas")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AgrupacionPoliticaId");
|
||||
|
||||
b.HasIndex("AmbitoGeograficoId", "CategoriaId", "AgrupacionPoliticaId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("ProyeccionesBancas");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.ResultadoVoto", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<string>("AgrupacionPoliticaId")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int>("AmbitoGeograficoId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<long>("CantidadVotos")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("CategoriaId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("PorcentajeVotos")
|
||||
.HasPrecision(18, 4)
|
||||
.HasColumnType("decimal(18,4)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AgrupacionPoliticaId");
|
||||
|
||||
b.HasIndex("AmbitoGeograficoId", "CategoriaId", "AgrupacionPoliticaId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("ResultadosVotos");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.ResumenVoto", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AgrupacionPoliticaId")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int>("AmbitoGeograficoId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<long>("Votos")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<decimal>("VotosPorcentaje")
|
||||
.HasPrecision(5, 2)
|
||||
.HasColumnType("decimal(5,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AgrupacionPoliticaId");
|
||||
|
||||
b.ToTable("ResumenesVotos");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.Telegrama", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int>("AmbitoGeograficoId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ContenidoBase64")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("EleccionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("FechaEscaneo")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("FechaTotalizacion")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
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")
|
||||
.WithMany()
|
||||
.HasForeignKey("AgrupacionPoliticaId");
|
||||
|
||||
b.Navigation("AgrupacionPolitica");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.CandidatoOverride", b =>
|
||||
{
|
||||
b.HasOne("Elecciones.Database.Entities.AgrupacionPolitica", "AgrupacionPolitica")
|
||||
.WithMany()
|
||||
.HasForeignKey("AgrupacionPoliticaId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Elecciones.Database.Entities.AmbitoGeografico", "AmbitoGeografico")
|
||||
.WithMany()
|
||||
.HasForeignKey("AmbitoGeograficoId");
|
||||
|
||||
b.HasOne("Elecciones.Database.Entities.CategoriaElectoral", "CategoriaElectoral")
|
||||
.WithMany()
|
||||
.HasForeignKey("CategoriaId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("AgrupacionPolitica");
|
||||
|
||||
b.Navigation("AmbitoGeografico");
|
||||
|
||||
b.Navigation("CategoriaElectoral");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.EstadoRecuento", b =>
|
||||
{
|
||||
b.HasOne("Elecciones.Database.Entities.AmbitoGeografico", "AmbitoGeografico")
|
||||
.WithMany()
|
||||
.HasForeignKey("AmbitoGeograficoId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("AmbitoGeografico");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.EstadoRecuentoGeneral", b =>
|
||||
{
|
||||
b.HasOne("Elecciones.Database.Entities.CategoriaElectoral", "CategoriaElectoral")
|
||||
.WithMany()
|
||||
.HasForeignKey("CategoriaId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CategoriaElectoral");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.OcupanteBanca", b =>
|
||||
{
|
||||
b.HasOne("Elecciones.Database.Entities.Bancada", "Bancada")
|
||||
.WithOne("Ocupante")
|
||||
.HasForeignKey("Elecciones.Database.Entities.OcupanteBanca", "BancadaId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Bancada");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.ProyeccionBanca", b =>
|
||||
{
|
||||
b.HasOne("Elecciones.Database.Entities.AgrupacionPolitica", "AgrupacionPolitica")
|
||||
.WithMany()
|
||||
.HasForeignKey("AgrupacionPoliticaId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Elecciones.Database.Entities.AmbitoGeografico", "AmbitoGeografico")
|
||||
.WithMany()
|
||||
.HasForeignKey("AmbitoGeograficoId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("AgrupacionPolitica");
|
||||
|
||||
b.Navigation("AmbitoGeografico");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.ResultadoVoto", b =>
|
||||
{
|
||||
b.HasOne("Elecciones.Database.Entities.AgrupacionPolitica", "AgrupacionPolitica")
|
||||
.WithMany()
|
||||
.HasForeignKey("AgrupacionPoliticaId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Elecciones.Database.Entities.AmbitoGeografico", "AmbitoGeografico")
|
||||
.WithMany()
|
||||
.HasForeignKey("AmbitoGeograficoId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("AgrupacionPolitica");
|
||||
|
||||
b.Navigation("AmbitoGeografico");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Elecciones.Database.Entities.ResumenVoto", 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.Navigation("Ocupante");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,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");
|
||||
@@ -148,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")
|
||||
@@ -546,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")
|
||||
|
||||
@@ -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+5a8bee52d57b0f215705f3a7efb654169f85a7ae")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+67634ae947197595f6f644f3a80a982dd3573dfb")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Elecciones.Database")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Elecciones.Database")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Elecciones.Infrastructure")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+5a8bee52d57b0f215705f3a7efb654169f85a7ae")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+67634ae947197595f6f644f3a80a982dd3573dfb")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Elecciones.Infrastructure")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Elecciones.Infrastructure")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
Reference in New Issue
Block a user