示例#1
0
 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;
 });
示例#2
0
        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);
        });
示例#3
0
        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));
        }
示例#4
0
 public Task Handle(OrderItemAddedEvent notification, CancellationToken cancellationToken)
 {
     return(Task.CompletedTask);
 }