Minor refactoring related to the ProductPriceChanged integration event
This commit is contained in:
parent
faf4ada8ac
commit
e41ce96f81
@ -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)
|
||||||
|
@ -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…
x
Reference in New Issue
Block a user