Exemple #1
0
 public static Order CreateFromShoppingCart(int temporaryId, ShoppingCart cart)
 {
     var order = new Order(temporaryId, cart.Buyer);
     foreach (var cartItem in cart.Items)
     {
         var orderItem = OrderItem.CreateNewForOrder(order, cartItem.Quantity, cartItem.Product);
         order.Items.Add(orderItem);
         order.Total = cart.GetTotal();
     }
     return order;
 }
        public LowStockReport CheckStockLevelForOrderedItems(ShoppingCart cart)
        {
            var threshold = GetCriticalThresholdForStock();

            var requestedProducts = (from p in cart.Items select p.Product).ToArray();
            var criticalProducts = _productRepository.FindProductBelowStockLevel(requestedProducts, threshold);

            var stock = new LowStockReport();
            foreach (var item in criticalProducts)
            {
                var quantityOrdered = (from p in cart.Items where p.Product.Id == item.Id select p.Quantity).Single();
                if (item.StockLevel - quantityOrdered <= 0)
                {
                    stock.Insufficient.Add(item);
                }
                else
                {
                    stock.Low.Add(item);
                }
            }
            return stock;
        }
 public void SaveCheckoutInformation(ShoppingCart orderRequest, Address address, CreditCard card)
 {
     orderRequest.Buyer.SetAddress(address);
     orderRequest.Buyer.SetPaymentDetails(card);
     _customerRepository.Save(orderRequest.Buyer);
 }
 public static ShoppingCartViewModel CreateEmpty(ShoppingCart cart, ICollection<Product> products)
 {
     var model = new ShoppingCartViewModel {OrderRequest = cart, Products = products};
     return model;
 }
Exemple #5
0
 public static ShoppingCart CreateEmpty(Customer buyer)
 {
     var model = new ShoppingCart {Buyer = buyer};
     return model;
 }