using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using SkillManagementBLL.SkillMatrixConfig; using static GB5Shared.GB5Constant.Constant; namespace SkillManagementSL.EndPoints.SkillMatrixConfig { public class DeleteSkillMatrixConfig : BaseEndpoint> { private readonly ISkillMatrixConfigBLL _bll; public DeleteSkillMatrixConfig(ISkillMatrixConfigBLL bll) { _bll = bll; } public override void Configure() { Delete("/SkillMatrixConfig/DeleteSkillMatrixConfig"); AllowAnonymous(); } public record DeleteSkillMatrixConfigParameters( [property: FromHeader] string Login, [property: QueryParam] int ConfigId ); protected override string? GetCacheKey(DeleteSkillMatrixConfigParameters req, LoginDTO login) => $"Skill:MatrixConfig:{login.ClientId}:{req.ConfigId}"; protected override bool ShouldInvalidateCache(DeleteSkillMatrixConfigParameters req, LoginDTO login) => true; protected override async Task> ExecuteAsync( DeleteSkillMatrixConfigParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.Delete(req.ConfigId, login, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 500); } } } }