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