Feat Widgets
This commit is contained in:
		| @@ -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(); | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user