Ejemplo n.º 1
2
        private object DummyEcommerceMethod2()
        {
            SKUInfo          sku             = null;
            IOrderRepository orderRepository = null;
            int orderId = 0;

            //DocSection:DisplayCatalogDiscounts
            // Initializes the needed services
            ShoppingService shoppingService = new ShoppingService();
            PricingService  pricingService  = new PricingService();

            // Gets the current shopping cart
            ShoppingCart shoppingCart = shoppingService.GetCurrentShoppingCart();

            // Calculates prices for the specified product
            ProductPrice price = pricingService.CalculatePrice(sku, shoppingCart);

            // Gets the catalog discount
            decimal catalogDiscount = price.Discount;
            //EndDocSection:DisplayCatalogDiscounts

            //DocSection:DisplayOrderList
            // Gets the current customer
            Customer currentCustomer = shoppingService.GetCurrentCustomer();

            // If the customer does not exist, returns error 404
            if (currentCustomer == null)
            {
                return(HttpNotFound());
            }

            // Creates a view model representing a collection of the customer's orders
            OrdersViewModel model = new OrdersViewModel()
            {
                Orders = orderRepository.GetByCustomerId(currentCustomer.ID)
            };
            //EndDocSection:DisplayOrderList

            //DocSection:ReorderExistingOrder
            // Gets the order based on its ID
            Order order = orderRepository.GetById(orderId);

            // Gets the current visitor's shopping cart
            ShoppingCart cart = shoppingService.GetCurrentShoppingCart();

            // Loops through the items in the order and adds them to the shopping cart
            foreach (OrderItem item in order.OrderItems)
            {
                cart.AddItem(item.SKUID, item.Units);
            }

            // Evaluates the shopping cart
            cart.Evaluate();

            // Saves the shopping cart
            cart.Save();
            //EndDocSection:ReorderExistingOrder

            return(null);
        }
Ejemplo n.º 2
0
        private void DummyEcommerceMethod3()
        {
            //DocSection:DisplayFreeShippingOffers
            // Initializes the needed services
            ShoppingService shoppingService = new ShoppingService();
            PricingService  pricingService  = new PricingService();

            // Gets the current shopping cart
            ShoppingCart shoppingCart = shoppingService.GetCurrentShoppingCart();

            // Gets the remaining amount for free shipping
            decimal remainingFreeShipping = pricingService.CalculateRemainingAmountForFreeShipping(shoppingCart);
            //EndDocSection:DisplayFreeShippingOffers
        }