using EgwCoreLib.Lux.Data.Repository.Report; namespace EgwCoreLib.Lux.Data.Services.Report { public class ReportService : BaseServ, IReportService { #region Public Constructors public ReportService( IConfiguration config, IConnectionMultiplexer redis, IReportRepository repo) : base(config, redis) { _className = "Report"; _repo = repo; } #endregion Public Constructors #region Public Methods /// public async Task> GetAllAsync() { // Uso helper TraceAsync che gestisce automaticamente StartActivity, Log e Exception tracking return await TraceAsync($"{_className}.GetAllAsync", async (activity) => { return await GetOrSetCacheAsync( $"{_redisBaseKey}:{_className}:ALL", async () => await _repo.GetAllAsync() ); }); } /// public async Task UpsertAsync(ReportModel upsRec) { return await TraceAsync($"{_className}.Upsert", async (activity) => { var currRec = await _repo.GetByIdAsync(upsRec.ReportID); string operation = "UPDATE"; bool success = false; if (currRec != null) { success = await _repo.UpdateAsync(upsRec); } else { operation = "INSERT"; success = await _repo.AddAsync(upsRec); } activity?.SetTag("db.operation", operation); if (success) { await ClearCacheAsync($"{_redisBaseKey}:{_className}:*"); } return success; }); } #endregion Public Methods #region Private Fields private readonly string _className; private readonly IReportRepository _repo; #endregion Private Fields } }