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