using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MaintenanceBLL.KeyComponent; using static GB5Shared.GB5Constant.Constant; namespace MaintenanceSL.FastEndPoints.KeyComponent { public class DeleteKeyComponent : BaseEndpoint> { private readonly IKeyComponentBLL _KeyComponentBLL; public DeleteKeyComponent(IKeyComponentBLL KeyComponentBLL) { _KeyComponentBLL = KeyComponentBLL; } public override void Configure() { Delete("/KeyComponent/DeleteKeyComponent"); AllowAnonymous(); } public record DeleteKeyComponentParameters( [property: FromHeader] string Login, [property: QueryParam] int KeyComponentId ); protected override async Task> ExecuteAsync(DeleteKeyComponentParameters req,LoginDTO loginDTO,CancellationToken ct) { try { var result = await _KeyComponentBLL.DeleteKeyComponent(req.KeyComponentId, loginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result,CacheKeyLevel.NOT_REQUIRED,loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex,CacheKeyLevel.NOT_REQUIRED,loginDTO,ex.Message,500); } } } }