using EgwCoreLib.Lux.Data.DbModel.Sales; using EgwCoreLib.Lux.Data.Services.Sales; namespace Lux.API.Controllers { [Route("api/[controller]")] [ApiController] public class ReportController : ControllerBase { /// /// Costruttore metodo /// /// public ReportController(IOfferService offService) { _offService = offService; // Configurazione serializzatore JSON per risolvere errore di loop circolare JSSettings = new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }; } private JsonSerializerSettings JSSettings; private IOfferService _offService; private static Logger Log = LogManager.GetCurrentClassLogger(); /// /// Chiamata GET: riceve ELENCO Offerte dato periodo /// GET: api/report/offert-list/?from=2026-01-01&to=2026-04-01 /// /// id univoco img /// [HttpGet("offert-list")] public async Task OffertList(DateTime from, DateTime to) { Stopwatch sw = new Stopwatch(); sw.Start(); // recupera dal DB l'offerta con le righe relative List offData = await _offService.GetFiltAsync(from, to); sw.Stop(); Log.Info($"OffertList | {from} --> {to} | {sw.Elapsed.TotalMilliseconds:N3} ms"); return Ok(offData); } /// /// Chiamata GET: riceve OffertID, restituisce Json offerta + righe /// GET: api/report/offert/1 /// /// id univoco img /// [HttpGet("offert/{id}")] public async Task Offert(int id) { Stopwatch sw = new Stopwatch(); sw.Start(); // recupera dal DB l'offerta con le righe relative OfferModel? offData = await _offService.GetByIdAsync(id); sw.Stop(); Log.Info($"Offert | {id} | {sw.Elapsed.TotalMilliseconds:N3} ms"); return Ok(offData); //string jsonRes = JsonConvert.SerializeObject(offData, JSSettings); //return Ok(jsonRes); } [HttpGet("version")] public string version() { var version = Assembly .GetExecutingAssembly() .GetName() .Version? .ToString() ?? "unknown"; return version; } } }