public static PurchasedProduct Create(Purchase purchase, CartProduct cartProduct)
 {
     return new PurchasedProduct()
     {
         Product = cartProduct.Product,
         Purchase = purchase,
         Quantity = cartProduct.Quantity
     };
 }
        public static Purchase Create(Customer customer, ReadOnlyCollection<CartProduct> cartProducts)
        {
            Purchase purchase = new Purchase()
            {
                Id = Guid.NewGuid(),
                Created = DateTime.Today,
                Customer = customer,
                TotalCost = customer.Cart.TotalCost,
                TotalTax = customer.Cart.TotalTax
            };

            List<PurchasedProduct> purchasedProducts = new List<PurchasedProduct>();
            foreach (CartProduct cartProduct in cartProducts)
            {
                purchasedProducts.Add(PurchasedProduct.Create(purchase, cartProduct));
            }

            purchase.purchasedProducts = purchasedProducts;

            return purchase;
        }
 internal virtual void Add(Purchase purchase)
 {
     this.purchases.Add(purchase);
 }