using FastEndpoints; using FrameworkBLL.Operation; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.Operation { public class GetOperation : BaseEndpoint> { private readonly IOperationBLL _OperationBLL; public GetOperation(IOperationBLL IOperationBLL) { _OperationBLL = IOperationBLL; } public override void Configure() { Get("/Operation/GetOperation"); AllowAnonymous(); } public record GetOperationParameters( [property: FromHeader] string Login, [property: QueryParam] int OperationId ); protected override string? GetCacheKey(GetOperationParameters Parameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(Parameters.OperationId!, EntityConstant.OBJECTOPERATION, FrameworkDAL.Constant.Constant.CacheKeyLevel.UserLevel, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetOperationParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _OperationBLL.GetOperation(req.OperationId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, FrameworkDAL.Constant.Constant.CacheKeyLevel.UserLevel, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, FrameworkDAL.Constant.Constant.CacheKeyLevel.UserLevel, LoginDTO, ex.Message, 500); } } } }