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