using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.GateEntry; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.GateEntry { public class GetGateEntry : BaseEndpoint> { private readonly IGateEntryBLL _GateEntryBLL; public GetGateEntry(IGateEntryBLL IGateEntryBLL) { _GateEntryBLL = IGateEntryBLL; } public override void Configure() { Get("/GateEntry/GetGateEntry"); AllowAnonymous(); } public record GetGateEntryParameters( [property: FromHeader] string Login, [property: QueryParam] int GateEntryId ); //protected override string? GetCacheKey(GetGateEntryParameters Parameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(Parameters.GateEntryId!, EntityConstant.OBJECTGATEENTRY, CacheKeyLevel.USER_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} protected override async Task> ExecuteAsync(GetGateEntryParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _GateEntryBLL.GetGateEntry(req.GateEntryId, 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); } } } }