|
@ -180,7 +180,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers |
|
|
catalogItem = productToUpdate; |
|
|
catalogItem = productToUpdate; |
|
|
_catalogContext.CatalogItems.Update(catalogItem); |
|
|
_catalogContext.CatalogItems.Update(catalogItem); |
|
|
|
|
|
|
|
|
if (raiseProductPriceChangedEvent) // Save and publish integration event if price has changed
|
|
|
|
|
|
|
|
|
if (raiseProductPriceChangedEvent) // Save product's data and publish integration event through the Event Bus if price has changed
|
|
|
{ |
|
|
{ |
|
|
//Create Integration Event to be published through the Event Bus
|
|
|
//Create Integration Event to be published through the Event Bus
|
|
|
var priceChangedEvent = new ProductPriceChangedIntegrationEvent(catalogItem.Id, productToUpdate.Price, oldPrice); |
|
|
var priceChangedEvent = new ProductPriceChangedIntegrationEvent(catalogItem.Id, productToUpdate.Price, oldPrice); |
|
@ -191,7 +191,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers |
|
|
// Publish through the Event Bus and mark the saved event as published
|
|
|
// Publish through the Event Bus and mark the saved event as published
|
|
|
await _catalogIntegrationEventService.PublishThroughEventBusAsync(priceChangedEvent); |
|
|
await _catalogIntegrationEventService.PublishThroughEventBusAsync(priceChangedEvent); |
|
|
} |
|
|
} |
|
|
else // Save updated product
|
|
|
|
|
|
|
|
|
else // Just save the updated product because the Product's Price hasn't changed.
|
|
|
{ |
|
|
{ |
|
|
await _catalogContext.SaveChangesAsync(); |
|
|
await _catalogContext.SaveChangesAsync(); |
|
|
} |
|
|
} |
|
|