Example #1
0
        public ActionResult DeliveryDetails(DeliveryDetailsViewModel model)
        {
            // Gets the current user's shopping cart
            ShoppingCart cart = shoppingService.GetCurrentShoppingCart();

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

            // If the ModelState is not valid, assembles the country list and the shipping option list and displays the step again
            if (!ModelState.IsValid)
            {
                SelectList countries = new SelectList(CountryInfoProvider.GetAllCountries(), "CountryID", "CountryDisplayName");
                model.BillingAddress.Countries       = countries;
                model.ShippingOption.ShippingOptions = new ShippingOptionModel(cart.ShippingOption, shippingOptions).ShippingOptions;
                return(View(model));
            }

            // Gets the shopping cart's customer and applies the customer details from the checkout process step
            if (cart.Customer == null)
            {
                cart.Customer = new Customer();
            }
            model.Customer.ApplyToCustomer(cart.Customer);

            // Gets the shopping cart's billing address and applies the billing address from the checkout process step
            cart.BillingAddress = addressRepository.GetById(model.BillingAddress.AddressID) ?? new CustomerAddress();
            model.BillingAddress.ApplyTo(cart.BillingAddress);

            // Sets the address personal name and saves the shopping cart
            cart.BillingAddress.PersonalName = $"{cart.Customer.FirstName} {cart.Customer.LastName}";
            cart.Save();

            // Redirects to the next step of the checkout process
            return(RedirectToAction("PreviewAndPay"));
        }
Example #2
0
 /// <summary>
 /// Gets the address with the specified identifier.
 /// </summary>
 /// <param name="addressID">Address identifier.</param>
 public AddressInfo GetAddress(int addressID)
 {
     return(mAddressRepository.GetById(addressID));
 }
Example #3
0
 /// <summary>
 /// Gets the address with the specified identifier.
 /// </summary>
 /// <param name="addressID">Address identifier.</param>
 public CustomerAddress GetAddress(int addressID)
 {
     return(mAddressRepository.GetById(addressID));
 }