コード例 #1
0
 public Order(OrderId id, string concertId, string userId, IEnumerable <OrderItem> items, IPriceCalculator priceCalculator)
 {
     if (string.IsNullOrWhiteSpace(concertId))
     {
         throw new ArgumentException("concert id should not be null", nameof(concertId));
     }
     Id = id ?? throw new ArgumentNullException(nameof(id));
     this.ApplyChange(new OrderPlaced(concertId, userId, items.ToList()));
     this.ApplyChange(new OrderTotalCalculated(priceCalculator.Total(items).ToValue()));
 }