43 lines
1.4 KiB
C#
43 lines
1.4 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using bdAntifraude.dbcontext;
|
|
using SwaggerAntifraude.Controllers;
|
|
using bdAntifraude.vistas;
|
|
using System.ComponentModel;
|
|
using Microsoft.AspNetCore.Authorization; // Asegúrate de importar el namespace correcto para VePersonas
|
|
|
|
namespace SwaggerAntifraude.Controllers
|
|
{
|
|
[Authorize]
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class VePersonasController : ControllerBase
|
|
{
|
|
/// <summary>
|
|
/// Obtiene una lista de VePersonas con un filtro opcional de activos.
|
|
/// </summary>
|
|
/// <param name="activos">Indica si solo se deben devolver las personas activas.</param>
|
|
/// <returns>Lista de VePersonas.</returns>
|
|
[Authorize(Policy = "LecturaPolicy")]
|
|
[HttpGet]
|
|
public IActionResult ObtenerVistaPersonas(bool activos = true)
|
|
{
|
|
try
|
|
{
|
|
using (var context = tsGestionAntifraude.NuevoContexto(SoloLectura: true, UseLazyLoadingProxies: true))
|
|
{
|
|
// Llamar al método ObtenerVistaPersonas
|
|
var personas = VePersonas.ObtenerVistaPersonas(context, activos);
|
|
|
|
|
|
|
|
return Ok(personas);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(500, $"Error interno del servidor: {ex.Message}");
|
|
}
|
|
}
|
|
}
|
|
}
|