using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using TMSBLL.PaperSection; using TMSSL.EndPoints.PaperSection; using static GB5Shared.GB5Constant.Constant; namespace TMSSL.EndPoints.PaperSection { public class DeletePaperSection : BaseEndpoint> { private readonly IPaperSectionBLL _PaperSectionBLL; public DeletePaperSection(IPaperSectionBLL PaperSectionBLL) { _PaperSectionBLL = PaperSectionBLL; } public override void Configure() { Delete("/PaperSection/DeletePaperSection"); AllowAnonymous(); } public record DeletePaperSectionParameters( [property: QueryParam] int PaperSectionId, [property: FromHeader] string Login ); protected override string? GetCacheKey(DeletePaperSectionParameters req, LoginDTO loginDTO) => KeyGenerator.KeyGeneration(req.PaperSectionId, EntityConstant.OBJECTPAPERSECTION, CacheKeyLevel.CLIENT_LEVEL, loginDTO); protected override bool ShouldInvalidateCache(DeletePaperSectionParameters req, LoginDTO loginDTO) => true; protected override async Task> ExecuteAsync(DeletePaperSectionParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _PaperSectionBLL.DeletePaperSection(req.PaperSectionId, 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); } } } }