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