using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.Perquisites; using PayRollDAL.DTO.Perq; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.Perquisites { public class SavePerquisites : BaseEndpoint> { private readonly IPerquisitesBLL _PerquisitesBLL; public SavePerquisites(IPerquisitesBLL IPerquisitesBLL) { _PerquisitesBLL = IPerquisitesBLL; } public override void Configure() { Post("/Perquisites/SavePerquisites"); AllowAnonymous(); } public record SavePerquisitesParameters( [property: FromHeader] string Login, [property: FromBody] PerqDTO PerqDTO ); protected override async Task> ExecuteAsync(SavePerquisitesParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _PerquisitesBLL.SavePerquisites(req.PerqDTO, 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); } } } }