using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using TMSBLL.PaperSection; using TMSSL.EndPoints.PaperSection; using static GB5Shared.GB5Constant.Constant; namespace TMSSL.EndPoints.PaperSection { public class GetPaperSectionList : BaseEndpoint> { private readonly IPaperSectionBLL _PaperSectionBLL; public GetPaperSectionList(IPaperSectionBLL PaperSectionBLL) { _PaperSectionBLL = PaperSectionBLL; } public override void Configure() { Get("/PaperSection/GetPaperSectionList"); AllowAnonymous(); } public record GetPaperSectionListParameters( [property: FromHeader] string Login, [property: QueryParam] int AssessmentPaperId ); protected override string? GetCacheKey(GetPaperSectionListParameters req, LoginDTO loginDTO) { try { return KeyGenerator.KeyGeneration(loginDTO.ClientId, EntityConstant.OBJECTPAPERSECTION, CacheKeyLevel.CLIENT_LEVEL, loginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetPaperSectionListParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _PaperSectionBLL.GetPaperSectionList(req.AssessmentPaperId,loginDTO); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, loginDTO, ex.Message, 500); } } } }