Feat Widgets 1541

This commit is contained in:
2025-09-02 15:39:17 -03:00
parent da581d9714
commit f961f9d8e7
16 changed files with 1306 additions and 81 deletions

View File

@@ -187,22 +187,52 @@ public class AdminController : ControllerBase
[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);
.FirstOrDefaultAsync(l =>
l.AgrupacionPoliticaId == logo.AgrupacionPoliticaId &&
l.CategoriaId == logo.CategoriaId &&
l.AmbitoGeograficoId == logo.AmbitoGeograficoId);
if (logoExistente != null)
{
// Si encontramos el registro exacto, solo actualizamos su URL.
logoExistente.LogoUrl = logo.LogoUrl;
}
else if (!string.IsNullOrEmpty(logo.LogoUrl))
{
_dbContext.LogosAgrupacionesCategorias.Add(logo);
// Si no se encontró un registro exacto (es un override nuevo),
// lo añadimos a la base de datos.
_dbContext.LogosAgrupacionesCategorias.Add(new LogoAgrupacionCategoria
{
AgrupacionPoliticaId = logo.AgrupacionPoliticaId,
CategoriaId = logo.CategoriaId,
AmbitoGeograficoId = logo.AmbitoGeograficoId,
LogoUrl = logo.LogoUrl
});
}
}
await _dbContext.SaveChangesAsync();
return NoContent();
}
[HttpGet("catalogos/municipios")]
public async Task<IActionResult> GetMunicipiosForAdmin()
{
var municipios = await _dbContext.AmbitosGeograficos
.AsNoTracking()
.Where(a => a.NivelId == 30) // Nivel 30 = Municipio
.OrderBy(a => a.Nombre)
.Select(a => new
{
// Devolvemos el ID de la base de datos como un string,
// que es lo que el componente Select espera.
Id = a.Id.ToString(),
Nombre = a.Nombre
})
.ToListAsync();
return Ok(municipios);
}
}

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="GetEFProjectMetadata">
<MSBuild Condition=" '$(TargetFramework)' == '' "
Projects="$(MSBuildProjectFile)"
Targets="GetEFProjectMetadata"
Properties="TargetFramework=$(TargetFrameworks.Split(';')[0]);EFProjectMetadataFile=$(EFProjectMetadataFile)" />
<ItemGroup Condition=" '$(TargetFramework)' != '' ">
<EFProjectMetadata Include="AssemblyName: $(AssemblyName)" />
<EFProjectMetadata Include="Language: $(Language)" />
<EFProjectMetadata Include="OutputPath: $(OutputPath)" />
<EFProjectMetadata Include="Platform: $(Platform)" />
<EFProjectMetadata Include="PlatformTarget: $(PlatformTarget)" />
<EFProjectMetadata Include="ProjectAssetsFile: $(ProjectAssetsFile)" />
<EFProjectMetadata Include="ProjectDir: $(ProjectDir)" />
<EFProjectMetadata Include="RootNamespace: $(RootNamespace)" />
<EFProjectMetadata Include="RuntimeFrameworkVersion: $(RuntimeFrameworkVersion)" />
<EFProjectMetadata Include="TargetFileName: $(TargetFileName)" />
<EFProjectMetadata Include="TargetFrameworkMoniker: $(TargetFrameworkMoniker)" />
<EFProjectMetadata Include="Nullable: $(Nullable)" />
<EFProjectMetadata Include="TargetFramework: $(TargetFramework)" />
<EFProjectMetadata Include="TargetPlatformIdentifier: $(TargetPlatformIdentifier)" />
</ItemGroup>
<WriteLinesToFile Condition=" '$(TargetFramework)' != '' "
File="$(EFProjectMetadataFile)"
Lines="@(EFProjectMetadata)" />
</Target>
</Project>