示例#1
0
        public ActionResult ItemList()
        {
            var model = ShoppingViewModelFactory.Create <ItemListViewModel>(PropertyBag);

            model.Categories = Exigo.GetWebCategoriesRecursively(OrderConfiguration.CategoryID);

            return(View(model));
        }
示例#2
0
        public ActionResult Shipping()
        {
            var model = ShoppingViewModelFactory.Create <ShippingAddressesViewModel>(PropertyBag);

            model.Addresses = Exigo.GetCustomerAddresses(Identity.Current.CustomerID)
                              .Where(c => c.IsComplete)
                              .Select(c => c as ShippingAddress);

            return(View(model));
        }
示例#3
0
        public ActionResult Cart()
        {
            var model      = ShoppingViewModelFactory.Create <CartViewModel>(PropertyBag);
            var languageID = Exigo.GetSelectedLanguageID();

            // Get the cart items
            var cartItems = ShoppingCart.Items.ToList();

            model.Items = Exigo.GetItems(cartItems, OrderConfiguration, languageID).ToList();

            return(View(model));
        }
示例#4
0
        public ActionResult Payment()
        {
            var model = ShoppingViewModelFactory.Create <PaymentMethodsViewModel>(PropertyBag);

            model.PaymentMethods = Exigo.GetCustomerPaymentMethods(new GetCustomerPaymentMethodsRequest
            {
                CustomerID = Identity.Current.CustomerID,
                ExcludeIncompleteMethods = true,
                ExcludeInvalidMethods    = true
            });
            model.Addresses = Exigo.GetCustomerAddresses(Identity.Current.CustomerID)
                              .Where(c => c.IsComplete)
                              .Select(c => c as ShippingAddress);

            return(View("Payment", model));
        }
示例#5
0
        public ActionResult ItemDetail(string itemcode)
        {
            var model      = ShoppingViewModelFactory.Create <ItemDetailViewModel>(PropertyBag);
            var languageID = Exigo.GetSelectedLanguageID();

            model.Item = Exigo.GetItems(new ExigoService.GetItemsRequest
            {
                Configuration = OrderConfiguration,
                ItemCodes     = new List <string> {
                    itemcode
                }.ToArray(),
                LanguageID = languageID
            }).FirstOrDefault();

            if (model.Item != null)
            {
                model.Item.Quantity = 1;
            }

            return(View(model));
        }
示例#6
0
        public ActionResult Payment()
        {
            var model = ShoppingViewModelFactory.Create <PaymentMethodsViewModel>(PropertyBag);

            if (Identity.Customer != null)
            {
                model.PaymentMethods = Exigo.GetCustomerPaymentMethods(new GetCustomerPaymentMethodsRequest
                {
                    CustomerID = Identity.Customer.CustomerID,
                    ExcludeIncompleteMethods = true,
                    ExcludeInvalidMethods    = true
                });
                model.Addresses = Exigo.GetCustomerAddresses(Identity.Customer.CustomerID)
                                  .Where(c => c.IsComplete)
                                  .Select(c => c as ShippingAddress);
            }

            ViewBag.HasAutoOrderItems = ShoppingCart.Items.Count(c => c.Type == ShoppingCartItemType.AutoOrder) > 0;

            return(View("Payment", model));
        }
        public ActionResult AutoOrder()
        {
            var model = ShoppingViewModelFactory.Create <AutoOrderSettingsViewModel>(PropertyBag);

            // Ensure we have a valid frequency type
            if (!GlobalSettings.AutoOrders.AvailableFrequencyTypes.Contains(PropertyBag.AutoOrderFrequencyType))
            {
                PropertyBag.AutoOrderFrequencyType = GlobalSettings.AutoOrders.AvailableFrequencyTypes.FirstOrDefault();
            }

            // Ensure we have a valid start date based on the frequency
            if (PropertyBag.AutoOrderStartDate == DateTime.MinValue.ToCST())
            {
                PropertyBag.AutoOrderStartDate = GlobalUtilities.GetAutoOrderStartDate(PropertyBag.AutoOrderFrequencyType);
            }


            // Set our model
            model.AutoOrderStartDate     = PropertyBag.AutoOrderStartDate;
            model.AutoOrderFrequencyType = PropertyBag.AutoOrderFrequencyType;

            return(View(model));
        }
示例#8
0
        public ActionResult Review()
        {
            var logicResult = LogicProvider.CheckLogic();

            if (!logicResult.IsValid)
            {
                return(logicResult.NextAction);
            }

            var model      = ShoppingViewModelFactory.Create <OrderReviewViewModel>(PropertyBag);
            var languageID = Exigo.GetSelectedLanguageID();


            #region Order Totals
            var beginningShipMethodID = PropertyBag.ShipMethodID;

            // If this is the first time coming to the page, and the property bag's ship method has not been set, then set it to the default for the configuration
            if (PropertyBag.ShipMethodID == 0)
            {
                PropertyBag.ShipMethodID = OrderConfiguration.DefaultShipMethodID;
                beginningShipMethodID    = PropertyBag.ShipMethodID;
                Exigo.PropertyBags.Update(PropertyBag);
            }


            // Get the cart items
            var cartItems = ShoppingCart.Items.ToList();
            model.Items = Exigo.GetItems(cartItems, OrderConfiguration, languageID).ToList();

            model.OrderTotals = Exigo.CalculateOrder(new OrderCalculationRequest
            {
                Configuration     = OrderConfiguration,
                Items             = cartItems,
                Address           = PropertyBag.ShippingAddress,
                ShipMethodID      = PropertyBag.ShipMethodID,
                ReturnShipMethods = true
            });
            model.ShipMethods = model.OrderTotals.ShipMethods;

            // Set the default ship method
            if (model.ShipMethods.Count() > 0)
            {
                if (model.ShipMethods.Any(c => c.ShipMethodID == PropertyBag.ShipMethodID))
                {
                    // If the property bag ship method ID exists in the results from order calc, set the correct result as selected
                    model.ShipMethods.First(c => c.ShipMethodID == PropertyBag.ShipMethodID).Selected = true;
                }
                else
                {
                    // If we don't have the ship method we're supposed to select, check the first one, save the selection and recalculate
                    model.ShipMethods.First().Selected = true;

                    // If for some reason the property bag is outdated and the ship method stored in it is not in the list, set the first result as selected and re-set the property bag's value
                    PropertyBag.ShipMethodID = model.ShipMethods.FirstOrDefault().ShipMethodID;
                    Exigo.PropertyBags.Update(PropertyBag);
                }
            }

            // If the original property bag value has changed from the beginning of the call, re-calculate the values
            if (beginningShipMethodID != PropertyBag.ShipMethodID)
            {
                var newCalculationResult = Exigo.CalculateOrder(new OrderCalculationRequest
                {
                    Configuration     = OrderConfiguration,
                    Items             = cartItems,
                    Address           = PropertyBag.ShippingAddress,
                    ShipMethodID      = PropertyBag.ShipMethodID,
                    ReturnShipMethods = false,
                    CustomerID        = Identity.Current.CustomerID
                });

                model.OrderTotals = newCalculationResult;
            }
            #endregion

            return(View(model));
        }