using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.Employee; using PayRollDAL.DTO.Employee; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.Employee { public class SaveEmployee : BaseEndpoint> { private readonly IEmployeeBLL _EmployeeBLL; public SaveEmployee(IEmployeeBLL EmployeeBLL) { _EmployeeBLL = EmployeeBLL; } public override void Configure() { Post("/Employee/SaveEmployee"); AllowAnonymous(); } public record SaveEmployeeParameters( [property: FromBody] EmployeeDTO EmployeeDTO, [property: FromHeader] string Login ); protected override async Task> ExecuteAsync(SaveEmployeeParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _EmployeeBLL.SaveEmployee(req.EmployeeDTO, LoginDTO.LanguageId, 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); } } } }