public async Task <IActionResult> IncluirChecklistItemChecklist([FromBody] ChecklistItemChecklistItem checklistItemChecklistToSave) { string msgRule = ""; _configuracaoContext.ChecklistItemChecklistItems.Add(checklistItemChecklistToSave); //Create Integration Event to be published through the Event Bus var checklistItemChecklistSaveEvent = new ChecklistItemChecklistIncluirIE(checklistItemChecklistToSave.Id_Checklist, checklistItemChecklistToSave.Id_ItemChecklist); try { // Achieving atomicity between original Catalog database operation and the IntegrationEventLog thanks to a local transaction await _configuracaoIntegrationEventService.IncluirEventAndChecklistItemChecklistContextChangesAsync(checklistItemChecklistSaveEvent); } catch (Exception e) { //Validações das CONSTRAINTS do BANCO if (ruleValidaChecklistItemChecklistPK(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(checklistItemChecklistSaveEvent); return(CreatedAtAction(nameof(IncluirChecklistItemChecklist), null)); }