public async Task <ActionResult> UpdateCarAsync([FromBody] Car carToUpdate)
        {
            var existingCarFromTheCatalog = await _carCatalogDbContext.Cars.SingleOrDefaultAsync(i => i.Id == carToUpdate.Id);

            if (existingCarFromTheCatalog == null)
            {
                return(NotFound(new { Message = $"Car with id {carToUpdate.Id} not found." }));
            }

            else
            {
                var oldPricePerDay        = existingCarFromTheCatalog.PricePerDay;
                var hasPricePerDayChanged = existingCarFromTheCatalog.PricePerDay != carToUpdate.PricePerDay;
                existingCarFromTheCatalog.PricePerDay = carToUpdate.PricePerDay;

                _carCatalogDbContext.Cars.Update(existingCarFromTheCatalog);

                if (hasPricePerDayChanged)
                {
                    var pricePerDayChangedEvent = new CarPricePerDayChangedIntegrationEvent(existingCarFromTheCatalog.Id,
                                                                                            existingCarFromTheCatalog.PricePerDay,
                                                                                            oldPricePerDay);

                    await _catalogIntegrationEventService.AddAndSaveEventAsync(pricePerDayChangedEvent);

                    await _catalogIntegrationEventService.PublishEventsThroughEventBusAsync(pricePerDayChangedEvent);
                }

                else
                {
                    await _carCatalogDbContext.SaveChangesAsync();
                }
                return(NoContent());
            }
        }
        public async Task <IActionResult> Add([FromBody] Product catalogItem)
        {
            // TODO - Extraer el saveContext a un repository para aplicar el repository pattern.
            var catalogItemAdded = catalogContext.Add(catalogItem);
            await catalogContext.SaveChangesAsync();

            var productAddedEvent = new ProductAddedIntegrationEvent(catalogItem);
            await catalogIntegrationEventService.AddAndSaveEventAsync(productAddedEvent);

            await catalogIntegrationEventService.PublishEventsThroughEventBusAsync(productAddedEvent);

            return(Ok(catalogItemAdded.Entity.Id));
            //return CreatedAtAction(nameof(GetCatalogItem), new { id = catalogItemAdded.Entity.Id });
        }