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 TIPOSTRAMOSController : GenericoController<TIPOSTRAMOS, int>
    {
        public TIPOSTRAMOSController()
           : base()
        {
        }

        [HttpGet]
        public override async Task<IActionResult> GetAll()
        {
            try
            {
                using (var context = tsGestionAntifraude.NuevoContexto(SoloLectura: true, UseLazyLoadingProxies: false))
                {
                    var entities = await context.TIPOSTRAMOS
                     .Include(x => x.IDTIPOTRAMOFICHEROXMLNavigation)
                     .Include(x => x.IDCODIGOTRAMOACUMULANavigation)
                     .Include(x => x.IDREGIMENAPLICACIONNavigation)
                        .AsNoTracking()
                        .ToListAsync();
                    //.Include(v => v.IDSERVICIOADSCRITONavigation)
                    //.Include(v => v.IDUNIDADADMINISTRATIVANavigation)
                    return Ok(entities);
                }
            }
            catch (Exception ex)
            {
                return StatusCode(500, $"Error interno del servidor: {ex.Message}");
            }
        }

    }
}
