Minor refactoring related to the ProductPriceChanged integration event

This commit is contained in:
Cesar De la Torre 2017-03-15 14:50:10 -07:00
parent faf4ada8ac
commit e41ce96f81
2 changed files with 7 additions and 7 deletions

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)

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;
} }