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 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( | ||||
|             orderStatusChangedToPaidDomainEvent.OrderId, | ||||
| @ -43,7 +43,8 @@ public class OrderStatusChangedToPaidDomainEventHandler | ||||
|         { | ||||
|             var productBoughtEvent = new ProductBoughtIntegrationEvent( | ||||
|                 orderStockItem.ProductId, | ||||
|                 orderStockItem.Units | ||||
|                 orderStockItem.Units, | ||||
|                 orderStockItem.Price | ||||
|             ); | ||||
|             await _orderingIntegrationEventService.AddAndSaveEventAsync(productBoughtEvent); | ||||
|         } | ||||
|  | ||||
| @ -22,9 +22,12 @@ public record OrderStockItem | ||||
|     public int ProductId { 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; | ||||
|         Units = units; | ||||
|         Price = price; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -5,9 +5,12 @@ public record ProductBoughtIntegrationEvent : IntegrationEvent | ||||
|     public int ProductId { get; } | ||||
|     public int Units { get; } | ||||
|      | ||||
|     public ProductBoughtIntegrationEvent(int productId, int units) | ||||
|     public decimal Price { get; } | ||||
| 
 | ||||
|     public ProductBoughtIntegrationEvent(int productId, int units, decimal price) | ||||
|     { | ||||
|         ProductId = productId; | ||||
|         Units = units; | ||||
|         Price = price; | ||||
|     } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user