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