Example #1
0
 public static OrderItemState.Result Create(OrderItemId id, OrderId orderId, ProductId productId, decimal unitPrice, decimal discount) =>
    new OrderItemState(id, productId, unitPrice, discount).ApplyEvent(new OrderItemAddedEvent(id, orderId, productId, unitPrice, discount));
Example #2
0
 internal OrderItemState(OrderItemId id, ProductId productId, decimal unitPrice, decimal discount) =>
Example #3
0
 private void EnsureValidState(OrderItemId id, ProductId productId, decimal unitPrice, decimal discount) =>
 this.ThrowsIf(_ => string.IsNullOrEmpty(id), new ArgumentNullException(id))
 .ThrowsIf(_ => string.IsNullOrEmpty(productId), new ArgumentNullException(productId))
 .ThrowsIf(_ => unitPrice < 0, new InvalidValueException(unitPrice.ToString()))
 .ThrowsIf(_ => discount < 0, new InvalidValueException(discount.ToString()));
 public static OrderState.Result AddOrderItem(OrderState state, OrderItemId itemId, ProductId productId,
                                              decimal unitPrice, decimal discount) =>
 state.ApplyEvent(new OrderItemAddedEvent(itemId, state.Id, productId, unitPrice, discount));