Пример #1
0
 public ShoppingCart(ShoppingCartId id)
     : this()
 {
     ApplyChange(new StartedShopping {
         CartId = id
     });
 }
Пример #2
0
 ShoppingCart()
 {
     Register <StartedShopping>(_ =>
     {
         _id         = new ShoppingCartId(_.CartId);
         _checkedOut = false;
         _items      = new Items();
     });
     Register <CheckedoutCart>(_ => _checkedOut = true);
     Register <AddedItemToCart>(_ => _items.Add(new Item(new ItemId(_.ItemId), _.Count)));
     Register <RemovedItemFromCart>(_ => _items.Remove(new ItemId(_.ItemId)));
     Register <IncrementedItemCountInCart>(_ => _items.Get(new ItemId(_.ItemId)).Increment());
     Register <DecrementedItemCountInCart>(_ => _items.Get(new ItemId(_.ItemId)).Decrement());
 }