using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MaintenanceBLL.Claim; using static GB5Shared.GB5Constant.Constant; namespace MaintenanceSL.EndPoints.Claim { public class DeleteClaim : BaseEndpoint> { private readonly IClaimBLL _ClaimBLL; public DeleteClaim(IClaimBLL claimBLL) { _ClaimBLL = claimBLL; } public override void Configure() { Delete("/Claim/DeleteClaim"); AllowAnonymous(); } public record DeleteClaimParameters( [property: FromHeader] string Login, [property: QueryParam] int ClaimId ); protected override async Task> ExecuteAsync( DeleteClaimParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _ClaimBLL.DeleteClaim(req.ClaimId, LoginDTO!, ct); 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); } } } }