using GB5Shared.FastEndPoint; using PayRollBLL.PayProduction; using PayRollDAL.DTO.PayProduction; using GB5Shared.DTO.Framework.Login; using static GB5Shared.GB5Constant.Constant; using GB5Shared.DTO.PubSub; using GB5Shared.DTO.Framework.ResponseStandard; namespace PayRollSL.EndPoints.PayProduction { public sealed class SavePayProduction: BaseEndpoint { private readonly IPayProductionBLL _payProductionBLL; private string? ResultForEventData; public SavePayProduction(IPayProductionBLL payProductionBLL) { _payProductionBLL = payProductionBLL; } public override void Configure() { Post("/PayProduction/SavePayProduction"); AllowAnonymous(); } protected override PublishDTO? GetTopicName(PublishDTO? PublishDTO) { PublishDTO = new(); PublishDTO.EventText = "SavePayProduction"; PublishDTO.EventTypeId = EventTypeConstant.SAVEPAYPRODUCTION; PublishDTO.Data = ResultForEventData; PublishDTO.PubSubTopicName = "SavePayProduction"; return PublishDTO; } protected override async Task> ExecuteAsync(SavePayProductionParameters PayProductionParameter, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _payProductionBLL.SavePayProduction(PayProductionParameter.PayProductionDTO, LoginDTO!); ResultForEventData = Result ; 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); } } public record SavePayProductionParameters( [property: FastEndpoints.FromBody] PayProductionDTO PayProductionDTO, [property: FastEndpoints.FromHeader] LoginDTO Login ); } }