Browse Source

Minor refactoring related to the ProductPriceChanged integration event

pull/126/head
Cesar De la Torre 8 years ago
parent
commit
e41ce96f81
2 changed files with 7 additions and 7 deletions
  1. +3
    -3
      src/Services/Basket/Basket.API/Events/CatalogPriceChangedHandler.cs
  2. +4
    -4
      src/Services/Common/Infrastructure/Catalog/ProductPriceChanged.cs

+ 3
- 3
src/Services/Basket/Basket.API/Events/CatalogPriceChangedHandler.cs View File

@ -22,13 +22,13 @@ namespace Basket.API.Events
foreach (var id in userIds) foreach (var id in userIds)
{ {
var basket = await _repository.GetBasket(id); var basket = await _repository.GetBasket(id);
await UpdateBasket(@event.ItemId, @event.NewPrice, basket);
await UpdateBasket(@event.ProductId, @event.NewPrice, basket);
} }
} }
private async Task UpdateBasket(int itemId, decimal newPrice, CustomerBasket basket)
private async Task UpdateBasket(int productId, decimal newPrice, CustomerBasket basket)
{ {
var itemsToUpdate = basket?.Items?.Where(x => int.Parse(x.ProductId) == itemId).ToList();
var itemsToUpdate = basket?.Items?.Where(x => int.Parse(x.ProductId) == productId).ToList();
if (itemsToUpdate != null) if (itemsToUpdate != null)
{ {
foreach (var item in itemsToUpdate) foreach (var item in itemsToUpdate)


+ 4
- 4
src/Services/Common/Infrastructure/Catalog/ProductPriceChanged.cs View File

@ -6,15 +6,15 @@ namespace Microsoft.eShopOnContainers.Services.Common.Infrastructure.Catalog
{ {
public class ProductPriceChanged : IntegrationEventBase public class ProductPriceChanged : IntegrationEventBase
{ {
public int ItemId { get; private set; }
public int ProductId { get; private set; }
public decimal NewPrice { get; private set; } public decimal NewPrice { get; private set; }
public decimal OldPrice { get; set; }
public decimal OldPrice { get; private set; }
public ProductPriceChanged(int itemId, decimal newPrice, decimal oldPrice)
public ProductPriceChanged(int productId, decimal newPrice, decimal oldPrice)
{ {
ItemId = itemId;
ProductId = productId;
NewPrice = newPrice; NewPrice = newPrice;
OldPrice = oldPrice; OldPrice = oldPrice;
} }


Loading…
Cancel
Save