71 lines
2.1 KiB
C#
71 lines
2.1 KiB
C#
using bdAntifraude.db;
|
|
using bdAntifraude.dbcontext;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Serialize.Linq.Serializers;
|
|
using System.Linq.Expressions;
|
|
using SwaggerAntifraude.Controllers;
|
|
|
|
namespace SwaggerAntifraude.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class CONCEPTOSPUESTOSDETRABAJOController : GenericoController<CONCEPTOSPUESTOSDETRABAJO, int>
|
|
{
|
|
public CONCEPTOSPUESTOSDETRABAJOController()
|
|
: base()
|
|
{
|
|
}
|
|
|
|
[HttpGet]
|
|
public override async Task<IActionResult> GetAll()
|
|
{
|
|
try
|
|
{
|
|
using (var context = tsGestionAntifraude.NuevoContexto(SoloLectura: true, UseLazyLoadingProxies: false))
|
|
{
|
|
var entities = await context.CONCEPTOSPUESTOSDETRABAJO
|
|
//.Include(x => x.IDTIPOPERSONANavigation)
|
|
.AsNoTracking()
|
|
.ToListAsync();
|
|
return Ok(entities);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(500, $"Error interno del servidor: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
[Authorize(Policy = "LecturaPolicy")]
|
|
[HttpGet("{id}")]
|
|
public override IActionResult GetById(int id)
|
|
{
|
|
try
|
|
{
|
|
using (var context = tsGestionAntifraude.NuevoContexto(SoloLectura: true, UseLazyLoadingProxies: false))
|
|
{
|
|
//var dbSet = context.Set<VIDA_ADMINISTRATIVA>();
|
|
var entities = context.CONCEPTOSPUESTOSDETRABAJO
|
|
.AsNoTracking()
|
|
.FirstOrDefault(v => v.IDCONCEPTOSPUESTOSDETRABAJO == id);
|
|
|
|
|
|
|
|
if (entities == null)
|
|
return NotFound();
|
|
|
|
return Ok(entities);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(500, $"Error interno del servidor: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|