using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.NOCList; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.NOCList { public class DeleteNOCList : BaseEndpoint> { private readonly INOCListBLL _NOCListBLL; public DeleteNOCList(INOCListBLL nocListBLL) { _NOCListBLL = nocListBLL; } public override void Configure() { Delete("/NOCList/DeleteNOCList"); AllowAnonymous(); } public record DeleteNOCListParameters( [property: FromHeader] string Login, [property: QueryParam] int NOCListId ); protected override string? GetCacheKey(DeleteNOCListParameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync( DeleteNOCListParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _NOCListBLL.DeleteNOCList(req.NOCListId, 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); } } } }