using FastEndpoints; using FrameworkBLL.Action; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.Action { public class GetAction : BaseEndpoint { private readonly IActionBLL _actionBLL; public GetAction(IActionBLL actionBLL) { _actionBLL = actionBLL; } public override void Configure() { Get("/Action/GetAction"); AllowAnonymous(); } public record GetActionParameters( [property: QueryParam] int MActionId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetActionParameters parameters, LoginDTO loginDTO) { try { return KeyGenerator.KeyGeneration(parameters.MActionId, EntityConstant.OBJECTMACTION, CacheKeyLevel.USER_LEVEL, loginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetActionParameters parameters, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _actionBLL.GetAction(parameters.MActionId, 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); } } } }