using bdAntifraude.db;
using bdAntifraude.dbcontext;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using SwaggerAntifraude.Controllers;
using System.Diagnostics;

namespace SwaggerAntifraude.Controllers
{
    [ApiController]
    [Route("api/[controller]")]
    public class RPTController : GenericoController<RPT, int>
    {
        public RPTController()
             : base()
        {
        }

        public override async Task<IActionResult> GetAll()
        {
            try
            {
                using (var context = tsGestionAntifraude.NuevoContexto(SoloLectura: true, UseLazyLoadingProxies: false))
                {
                    var rpts = context.RPT
                        .Include(r => r.IDSITUACIONNavigation).ToList();

                    if (rpts == null)
                        return NotFound("Sin registros.");

                    return Ok(rpts);
                }
            }
            catch (Exception ex)
            {
                return StatusCode(500, $"Error interno del servidor: {ex.Message}");
            }
        }
    }
}
