using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using SkillManagementBLL.SkillAssessment; using static GB5Shared.GB5Constant.Constant; namespace SkillManagementSL.EndPoints.SkillAssessment { public class GetSkillAssessment : BaseEndpoint> { private readonly ISkillAssessmentBLL _bll; public GetSkillAssessment(ISkillAssessmentBLL bll) { _bll = bll; } public override void Configure() { Get("/SkillAssessment/GetSkillAssessment"); AllowAnonymous(); } public record GetSkillAssessmentParameters( [property: FromHeader] string Login, [property: QueryParam] int AssessmentId ); protected override string? GetCacheKey(GetSkillAssessmentParameters req, LoginDTO login) { try { return $"Skill:Assessment:{login.ClientId}:{req.AssessmentId}"; } catch (Exception) { throw; } } protected override async Task> ExecuteAsync( GetSkillAssessmentParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetSkillAssessment(req.AssessmentId, login, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, login, ex.Message, 500); } } } }