using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using TMSBLL.AssessmentAssignment; using static GB5Shared.GB5Constant.Constant; namespace TMSSL.EndPoints.AssessmentAssignment { public class GetAssessmentAssignment : BaseEndpoint { private readonly IAssessmentAssignmentBLL _AssessmentAssignmentBLL; public GetAssessmentAssignment(IAssessmentAssignmentBLL assessmentAssignmentBLL) { _AssessmentAssignmentBLL = assessmentAssignmentBLL; } public override void Configure() { Get("/AssessmentAssignment/GetAssessmentAssignment"); AllowAnonymous(); } public record Parameters( [property: QueryParam] int AssessmentAssignmentId, [property: FromHeader] string Login ); protected override string? GetCacheKey(Parameters req, LoginDTO loginDTO) => KeyGenerator.KeyGeneration(req.AssessmentAssignmentId, EntityConstant.OBJECTASSESSMENTASSIGNMENT, CacheKeyLevel.CLIENT_LEVEL, loginDTO); protected override async Task> ExecuteAsync(Parameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _AssessmentAssignmentBLL.GetAssessmentAssignment(req.AssessmentAssignmentId, loginDTO, ct); 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); } } } }