コード例 #1
0
ファイル: Basket.cs プロジェクト: chekkan/shopping-cart-kata
 public Basket(UserId userId, DateTime creationDate, Inventory inventory)
 {
     this.items     = new List <BasketItem>();
     this.inventory = inventory;
     UserId         = userId;
     CreationDate   = creationDate;
     Id             = new ShoppingCartId(Guid.NewGuid().ToString());
 }
コード例 #2
0
        public void MakePayment(UserId userId,
                                ShoppingCartId cartId,
                                PaymentDetails payment)
        {
            var order = this.orderService.Create(userId, cartId);

            try
            {
                var paymentReference = this.paymentGateway.Pay(order, userId, payment);
                this.orderConfirmation.Send(userId, order.Id, paymentReference);
                foreach (var item in order.Items)
                {
                    this.inventory.Sold(item.ProductId, item.Quantity);
                }
            }
            catch (Exception)
            {
                throw new PaymentFailure();
            }
        }