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