using FastEndpoints; using FrameworkBLL.EventLog; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.EventLog { public class GetEventLog : BaseEndpoint { private readonly IEventLogBLL _EventLogBLL; public GetEventLog(IEventLogBLL IEventLogBLL) { _EventLogBLL = IEventLogBLL; } public override void Configure() { Get("/EventLog/GetEventLog"); AllowAnonymous(); } public record GetEventLogParameters( [property: QueryParam] int EventLogId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetEventLogParameters GetEventLogParameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(GetEventLogParameters.EventLogId!, EntityConstant.OBJECTENVENTLOG, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetEventLogParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _EventLogBLL.GetEventLog(req.EventLogId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.USER_LEVEL, LoginDTO, ex.Message, 500); } } } }