Feat Widgets

This commit is contained in:
2025-09-01 14:04:40 -03:00
parent 608ae655be
commit 12860f2406
30 changed files with 1904 additions and 247 deletions

View File

@@ -50,7 +50,6 @@ public class AdminController : ControllerBase
// Actualizamos las propiedades de la entidad con los valores del DTO.
agrupacion.NombreCorto = agrupacionDto.NombreCorto;
agrupacion.Color = agrupacionDto.Color;
agrupacion.LogoUrl = agrupacionDto.LogoUrl;
// Guardamos los cambios en la base de datos.
await _dbContext.SaveChangesAsync();
@@ -178,4 +177,32 @@ public class AdminController : ControllerBase
return NoContent();
}
[HttpGet("logos")]
public async Task<IActionResult> GetLogos()
{
return Ok(await _dbContext.LogosAgrupacionesCategorias.AsNoTracking().ToListAsync());
}
[HttpPut("logos")]
public async Task<IActionResult> UpdateLogos([FromBody] List<LogoAgrupacionCategoria> logos)
{
// Lógica de "Upsert"
foreach (var logo in logos)
{
var logoExistente = await _dbContext.LogosAgrupacionesCategorias
.FirstOrDefaultAsync(l => l.AgrupacionPoliticaId == logo.AgrupacionPoliticaId && l.CategoriaId == logo.CategoriaId);
if (logoExistente != null)
{
logoExistente.LogoUrl = logo.LogoUrl;
}
else if (!string.IsNullOrEmpty(logo.LogoUrl))
{
_dbContext.LogosAgrupacionesCategorias.Add(logo);
}
}
await _dbContext.SaveChangesAsync();
return NoContent();
}
}