Add price to product bought event.
This commit is contained in:
parent
b4b9e6c8d6
commit
3a15243e36
@ -31,7 +31,7 @@ public class OrderStatusChangedToPaidDomainEventHandler
|
|||||||
var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString());
|
var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString());
|
||||||
|
|
||||||
var orderStockList = orderStatusChangedToPaidDomainEvent.OrderItems
|
var orderStockList = orderStatusChangedToPaidDomainEvent.OrderItems
|
||||||
.Select(orderItem => new OrderStockItem(orderItem.ProductId, orderItem.GetUnits()));
|
.Select(orderItem => new OrderStockItem(orderItem.ProductId, orderItem.GetUnits(), orderItem.GetUnitPrice()));
|
||||||
|
|
||||||
var orderStatusChangedToPaidIntegrationEvent = new OrderStatusChangedToPaidIntegrationEvent(
|
var orderStatusChangedToPaidIntegrationEvent = new OrderStatusChangedToPaidIntegrationEvent(
|
||||||
orderStatusChangedToPaidDomainEvent.OrderId,
|
orderStatusChangedToPaidDomainEvent.OrderId,
|
||||||
@ -43,7 +43,8 @@ public class OrderStatusChangedToPaidDomainEventHandler
|
|||||||
{
|
{
|
||||||
var productBoughtEvent = new ProductBoughtIntegrationEvent(
|
var productBoughtEvent = new ProductBoughtIntegrationEvent(
|
||||||
orderStockItem.ProductId,
|
orderStockItem.ProductId,
|
||||||
orderStockItem.Units
|
orderStockItem.Units,
|
||||||
|
orderStockItem.Price
|
||||||
);
|
);
|
||||||
await _orderingIntegrationEventService.AddAndSaveEventAsync(productBoughtEvent);
|
await _orderingIntegrationEventService.AddAndSaveEventAsync(productBoughtEvent);
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,12 @@ public record OrderStockItem
|
|||||||
public int ProductId { get; }
|
public int ProductId { get; }
|
||||||
public int Units { get; }
|
public int Units { get; }
|
||||||
|
|
||||||
public OrderStockItem(int productId, int units)
|
public decimal Price;
|
||||||
|
|
||||||
|
public OrderStockItem(int productId, int units, decimal price = Decimal.Zero)
|
||||||
{
|
{
|
||||||
ProductId = productId;
|
ProductId = productId;
|
||||||
Units = units;
|
Units = units;
|
||||||
|
Price = price;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,13 @@ public record ProductBoughtIntegrationEvent : IntegrationEvent
|
|||||||
{
|
{
|
||||||
public int ProductId { get; }
|
public int ProductId { get; }
|
||||||
public int Units { get; }
|
public int Units { get; }
|
||||||
|
|
||||||
|
public decimal Price { get; }
|
||||||
|
|
||||||
public ProductBoughtIntegrationEvent(int productId, int units)
|
public ProductBoughtIntegrationEvent(int productId, int units, decimal price)
|
||||||
{
|
{
|
||||||
ProductId = productId;
|
ProductId = productId;
|
||||||
Units = units;
|
Units = units;
|
||||||
|
Price = price;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user