48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using bdAntifraude.db;
|
|
using bdAntifraude.dbcontext;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace SwaggerAntifraude.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class CONSOLIDACION_GRADOController : GenericoController<CONSOLIDACION_GRADO, int>
|
|
{
|
|
public CONSOLIDACION_GRADOController()
|
|
: base()
|
|
{
|
|
}
|
|
|
|
|
|
[Authorize(Policy = "LecturaPolicy")]
|
|
[HttpGet("GetWithIncludes/{id}")]
|
|
public async Task<IActionResult> GetWithIncludes(int id)
|
|
{
|
|
try
|
|
{
|
|
using (var context = tsGestionAntifraude.NuevoContexto(SoloLectura: true, UseLazyLoadingProxies: false))
|
|
{
|
|
// Consulta con Includes necesarios
|
|
var entity = await context.CONSOLIDACION_GRADO
|
|
.Include(p => p.IDNIVELNavigation)
|
|
.AsNoTracking()
|
|
.Where(p => p.IDPERSONAL == id).ToListAsync(); // Filtra por IDPUESTO
|
|
|
|
// Verifica si la entidad no se encontró
|
|
if (entity == null)
|
|
return NotFound($"El puesto con ID {id} no fue encontrado.");
|
|
|
|
// Devuelve la entidad con las relaciones cargadas
|
|
return Ok(entity);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(500, $"Error interno del servidor: {ex.Message}");
|
|
}
|
|
}
|
|
}
|
|
}
|