Browse Source

Add price to product bought event.

pull/2110/head
Philipp Theyssen 1 year ago
parent
commit
3a15243e36
3 changed files with 11 additions and 4 deletions
  1. +3
    -2
      src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderPaid/OrderStatusChangedToPaidDomainEventHandler.cs
  2. +4
    -1
      src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs
  3. +4
    -1
      src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/ProductBoughtIntegrationEvent.cs

+ 3
- 2
src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderPaid/OrderStatusChangedToPaidDomainEventHandler.cs View File

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


+ 4
- 1
src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs View File

@ -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
- 1
src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/ProductBoughtIntegrationEvent.cs View File

@ -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…
Cancel
Save