Exemplo n.º 1
0
        //EndDocSection:CouponCode


        //DocSection:DisplayDelivery
        /// <summary>
        /// Displays the customer detail checkout process step without any additional functionality for registered customers.
        /// </summary>
        public ActionResult DeliveryDetails()
        {
            // Gets the current user's shopping cart
            ShoppingCart cart = shoppingService.GetCurrentShoppingCart();

            // If the shopping cart is empty, displays the shopping cart
            if (cart.IsEmpty)
            {
                return(RedirectToAction("ShoppingCart"));
            }

            // Gets all countries for the country selector
            SelectList countries = new SelectList(CountryInfoProvider.GetCountries(), "CountryID", "CountryDisplayName");

            // Gets all enabled shipping options for the shipping option selector
            SelectList shippingOptions = new SelectList(shippingOptionRepository.GetAllEnabled(), "ShippingOptionID", "ShippingOptionDisplayName");

            // Loads the customer details
            DeliveryDetailsViewModel model = new DeliveryDetailsViewModel
            {
                Customer       = new CustomerModel(cart.Customer),
                BillingAddress = new BillingAddressModel(cart.BillingAddress, countries, null),
                ShippingOption = new ShippingOptionModel(cart.ShippingOption, shippingOptions)
            };

            // Displays the customer details step
            return(View(model));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Checks if shipping option is among applicable shipping options for the shopping cart.
        /// </summary>
        /// <param name="shippingOptionId">ID of shipping option.</param>
        /// <returns>True if shipping option can be used in the shopping cart.</returns>
        public bool IsShippingOptionValid(int shippingOptionId)
        {
            var shippingOptions = mShippingOptionRepository.GetAllEnabled().ToList();

            return(shippingOptions.Exists(s => s.ShippingOptionID == shippingOptionId));
        }