Ejemplo n.º 1
0
        public async Task <ActionResult> CreateProduct([FromBody] Product product)
        {
            _applicationContext.Products.Add(product);
            var productCreatedEvent = new ProductCreatedIntegrationEvent(product);

            _integrationEventLogService.Save(productCreatedEvent);
            await _integrationContextEventService.SaveApplicationContextAndEventLogsContextChangesAsync();

            await _integrationContextEventService.PublishEvent(productCreatedEvent);

            return(CreatedAtAction(nameof(GetById), new { id = product.Id }, null));
        }