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