using FastEndpoints; using FrameworkBLL.ServiceRequestField; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.ServiceRequestField { public class DeleteServiceRequestField : BaseEndpoint> { private readonly IServiceRequestFieldBLL _serviceRequestFieldBLL; public DeleteServiceRequestField(IServiceRequestFieldBLL serviceRequestFieldBLL) { _serviceRequestFieldBLL = serviceRequestFieldBLL; } public override void Configure() { Delete("/ServiceRequestField/DeleteServiceRequestField"); AllowAnonymous(); } public record DeleteServiceRequestFieldParameters( [property: FromHeader] string Login, [property: QueryParam] int ServiceRequestFieldId ); protected override async Task> ExecuteAsync( DeleteServiceRequestFieldParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _serviceRequestFieldBLL.DeleteServiceRequestField(req.ServiceRequestFieldId, 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); } } } }