예제 #1
0
        private Order(//多参数私有构造函数,供本领域内部使用
            List <OrderProductData> orderProductsData,
            List <Product> allProducts,
            string currency,
            List <ConversionRate> conversionRates
            )
        {
            this._orderDate     = DateTime.UtcNow;
            this.Id             = new OrderId(Guid.NewGuid());
            this._orderProducts = new List <OrderProduct>();

            foreach (var orderProductData in orderProductsData)
            {
                var product = allProducts.Single(t => t.Id == orderProductData.ProductId);

                //把订单产品的事交给OrderProduct
                var orderProduct = OrderProduct.CreateForProduct(product, orderProductData.Quantity, currency, conversionRates);
                _orderProducts.Add(orderProduct);
            }

            this.CalculateOrderValue();
            this._status = OrderStatus.Placed;
        }
예제 #2
0
 public OrderChangedEvent(OrderId orderId)
 {
     this.OrderId = orderId;
 }
예제 #3
0
 public OrderRemovedEvent(OrderId orderId)
 {
     this.OrderId = orderId;
 }
예제 #4
0
 public OrderPlacedEvent(OrderId orderId)
 {
     OrderId = orderId;
 }