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