using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using SkillManagementBLL.Skill; using static GB5Shared.GB5Constant.Constant; namespace SkillManagementSL.EndPoints.Skill { public class DeleteSkill : BaseEndpoint> { private readonly ISkillBLL _bll; public DeleteSkill(ISkillBLL bll) { _bll = bll; } public override void Configure() { Delete("/Skill/DeleteSkill"); AllowAnonymous(); } public record DeleteSkillParameters( [property: FromHeader] string Login, [property: QueryParam] int SkillId ); protected override string? GetCacheKey(DeleteSkillParameters req, LoginDTO login) => $"Skill:Skill:{login.ClientId}:{req.SkillId}:0:0"; protected override bool ShouldInvalidateCache(DeleteSkillParameters req, LoginDTO login) => true; protected override async Task> ExecuteAsync( DeleteSkillParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.DeleteSkill(req.SkillId, login); 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); } } } }