using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.NDTCertificate; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.NDTCertificate { public class GetNDTCertificate : BaseEndpoint> { private readonly INDTCertificateBLL _NDTCertificateBLL; public GetNDTCertificate(INDTCertificateBLL NDTCertificateBLL) { _NDTCertificateBLL = NDTCertificateBLL; } public override void Configure() { Get("/NDTCertificate/GetNDTCertificate"); AllowAnonymous(); } public record GetNDTCertificateParameters( [property: FromHeader] string Login, [property: QueryParam] int NDTCertificateId ); protected override string? GetCacheKey(GetNDTCertificateParameters Parameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(Parameters.NDTCertificateId!, EntityConstant.OBJECTNDTCERTIFICATE, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetNDTCertificateParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _NDTCertificateBLL.GetNDTCertificate(req.NDTCertificateId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }