using AdminBLL.Allocation; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AdminSL.EndPoints.Allocation { public class DeleteAllocation : BaseEndpoint> { public readonly IAllocationBLL _AllocationBLL; public DeleteAllocation(IAllocationBLL IAllocationBLL) { _AllocationBLL = IAllocationBLL; } public override void Configure() { Delete("/Allocation/DeleteAllocation"); AllowAnonymous(); } public record DeleteAllocationParameters( [property: FromHeader] string Login, [property: QueryParam] int MAllocationId ); protected override async Task> ExecuteAsync(DeleteAllocationParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _AllocationBLL.DeleteAllocation(req.MAllocationId, 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); } } } }