using FastEndpoints; using FrameworkBLL.EntityRelation; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.EntityRelation { public class DeleteEntityRelation : BaseEndpoint> { private readonly IEntityRelationBLL _EntityRelationBLL; public DeleteEntityRelation(IEntityRelationBLL IEntityRelationBLL) { _EntityRelationBLL = IEntityRelationBLL; } public override void Configure() { Delete("/EntityRelation/DeleteEntityRelation"); AllowAnonymous(); } public record DeleteEntityRelationParameters( [property: FromHeader] string Login, [property: QueryParam] int EntityRelationId ); protected override async Task> ExecuteAsync(DeleteEntityRelationParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _EntityRelationBLL.DeleteEntityRelation(req.EntityRelationId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NotRequired, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NotRequired, LoginDTO, ex.Message, 500); } } } }