using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using Newtonsoft.Json; using SkillManagementBLL.SkillMatrix; using static GB5Shared.GB5Constant.Constant; namespace SkillManagementSL.EndPoints.SkillMatrix { public class GetSkillMatrixView : BaseEndpoint> { private readonly ISkillMatrixBLL _bll; public GetSkillMatrixView(ISkillMatrixBLL bll) { _bll = bll; } public override void Configure() { Get("/SkillMatrix/GetSkillMatrixView"); AllowAnonymous(); Summary(s => s.Summary = "Returns the skill matrix view for a specific configuration."); Tags("SkillMatrix"); } public record GetSkillMatrixViewParameters( [property: FromHeader] string Login, [property: QueryParam] int ConfigId ); //protected override string? GetCacheKey(GetSkillMatrixViewParameters req, LoginDTO login) //{ // try // { // return $"Skill:Matrix:{login.ClientId}:{req.ConfigId}"; // } // catch (Exception) // { // throw; // } //} protected override async Task> ExecuteAsync( GetSkillMatrixViewParameters req, LoginDTO login, CancellationToken ct) { try { var matrix = await _bll.BuildMatrix(req.ConfigId, login, ct); var result = JsonConvert.SerializeObject(matrix); 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); } } } }