public async Task <IActionResult> IncluirFluxoAutomaticoCheck([FromBody] FluxoAutomaticoCheckItem FluxoAutomaticoCheckToSave) { string msgRule = ""; _configuracaoContext.FluxoAutomaticoCheckItems.Add(FluxoAutomaticoCheckToSave); //Create Integration Event to be published through the Event Bus var fluxoAutomaticoCheckSaveEvent = new FluxoAutomaticoCheckIncluirIE( FluxoAutomaticoCheckToSave.Id_Checklist, FluxoAutomaticoCheckToSave.Id_TipoSituacaoAcomodacao, FluxoAutomaticoCheckToSave.Id_ItemChecklist, FluxoAutomaticoCheckToSave.Id_TipoAtividadeAcomodacao, FluxoAutomaticoCheckToSave.Cod_Resposta, FluxoAutomaticoCheckToSave.Cod_PermiteTotal); try { // Achieving atomicity between original Catalog database operation and the IntegrationEventLog thanks to a local transaction await _configuracaoIntegrationEventService.IncluirEventAndFluxoAutomaticoCheckContextChangesAsync(fluxoAutomaticoCheckSaveEvent); } catch (Exception e) { //Validações das CONSTRAINTS do BANCO if (ruleValidaFluxoAutomaticoPK(e.Message, ref msgRule)) { return(BadRequest(msgRule)); } else { return(BadRequest(e.Message)); } } // Publish through the Event Bus and mark the saved event as published await _configuracaoIntegrationEventService.PublishThroughEventBusAsync(fluxoAutomaticoCheckSaveEvent); return(CreatedAtAction(nameof(IncluirFluxoAutomaticoCheck), null)); }