private void When(OrderItemAddedEvent @event) => With(this, state => { state._id = new OrderItemId(@event.OrderItemId); state._orderId = new OrderId(@event.OrderId); state._productId = new ProductId(@event.ProductId); state._unitPrice = @event.UnitPrice; state._discount = @event.Discount; });
private void When(OrderItemAddedEvent @event) => With(this, state => { var newItem = OrderItem.Create(new OrderItemId(@event.OrderItemId), state.Id, new ProductId(@event.ProductId), @event.UnitPrice, @event.Discount); state._orderItems = state._orderItems ?? new List <OrderItemState>(); state._orderItems.Add(newItem.State); });
public void Create(IEnumerable <Product> orderItems, ShippingInfo shippingInfo) { var subtotal = 0m; foreach (var item in orderItems) { ApplyChange(OrderItemAddedEvent.Raise(Id, item.Id, item.ItemName, item.UnitPrice)); subtotal += item.UnitPrice; } ApplyChange(ShippingInfoUpdatedEvent.Raise(Id, shippingInfo.ContactName, shippingInfo.ContactPhone, shippingInfo.ShippingAddress)); ApplyChange(OrderCreatedEvent.Raise(Id, subtotal)); }
public Task Handle(OrderItemAddedEvent notification, CancellationToken cancellationToken) { return(Task.CompletedTask); }