using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.NDTReport; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.NDTReport { public class GetNDTReport : BaseEndpoint> { private readonly INDTReportBLL _NDTReportBLL; public GetNDTReport(INDTReportBLL NDTReportBLL) { _NDTReportBLL = NDTReportBLL; } public override void Configure() { Get("/NDTReport/GetNDTReport"); AllowAnonymous(); } public record GetNDTReportParameters( [property: FromHeader] string Login, [property: QueryParam] int NDTReportId ); protected override string? GetCacheKey(GetNDTReportParameters Parameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(Parameters.NDTReportId!, EntityConstant.OBJECTNDTREPORT, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetNDTReportParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _NDTReportBLL.GetNDTReport(req.NDTReportId, 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); } } } }