using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.Declaration; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.Declaration { public class GetDeclaration : BaseEndpoint> { private readonly IDeclarationBLL _DeclarationBLL; public GetDeclaration(IDeclarationBLL IDeclarationBLL) { _DeclarationBLL = IDeclarationBLL; } public override void Configure() { Get("/Declaration/GetDeclaration"); AllowAnonymous(); } public record GetDeclarationParameters( [property: FromHeader] string Login, [property: QueryParam] int DeclarationId ); protected override async Task> ExecuteAsync(GetDeclarationParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _DeclarationBLL.GetDeclaration(req.DeclarationId, 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); } } } }