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()); }
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(); } }