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