using FastEndpoints; using FrameworkBLL.GBPeriod; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.EndPoints.GBPeriod { public class DeleteGBPeriod : BaseEndpoint> { private readonly IGBPeriodBLL _GBPeriodBLL; public DeleteGBPeriod(IGBPeriodBLL GBPeriodBLL) { _GBPeriodBLL = GBPeriodBLL; } public override void Configure() { Delete("/GBPeriod/DeleteGBPeriod"); AllowAnonymous(); } public record DeleteGBPeriodParameters( [property: FromHeader] string Login, [property: QueryParam] int GBPeriodId ); protected override async Task> ExecuteAsync(DeleteGBPeriodParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _GBPeriodBLL.DeleteGBPeriod(req.GBPeriodId, 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 ); } } } }