Esempio n. 1
0
        /// <summary>
        /// Adds <see cref="Atomia.Store.AspNetMvc.Models.OrderFlowModel"/> to ViewBag.
        /// </summary>
        private void PopulateViewBag(ActionExecutingContext filterContext, OrderFlow orderFlow, OrderFlowStep currentStep, bool isQueryStringBased)
        {
            var resourceProvider = DependencyResolver.Current.GetService<IResourceProvider>();

            var orderFlowModel = new OrderFlowModel
            {
                IsQueryStringBased = isQueryStringBased,
                Name = orderFlow.Name,
                Steps = orderFlow.Steps.Select(s => new OrderFlowStepModel
                {
                    Name = s.Name,
                    Previous = s.Previous,
                    Next = s.Next,
                    StepNumber = s.StepNumber,
                    Title = resourceProvider.GetResource("StepTitle" + s.Name),
                    Description = resourceProvider.GetResource("StepDescription" + s.Name)
                }),
                CurrentStep = new OrderFlowStepModel
                {
                    Name = currentStep.Name,
                    Previous = currentStep.Previous,
                    Next = currentStep.Next,
                    StepNumber = currentStep.StepNumber,
                    Title = resourceProvider.GetResource("StepTitle" + currentStep.Name),
                    Description = resourceProvider.GetResource("StepDescription" + currentStep.Name)
                }
            };

            filterContext.Controller.ViewBag.OrderFlow = orderFlowModel;
        }
        /// <summary>
        /// Remove an <see cref="OrderFlow"/> from the collection
        /// </summary>
        /// <param name="orderFlowName">The name of the <see cref="OrderFlow"/> to remove</param>
        /// <returns>If the <see cref="OrderFlow"/> was removed or not.</returns>
        public bool Remove(string orderFlowName)
        {
            if (defaultOrderFlow != null && defaultOrderFlow.Name == orderFlowName)
            {
                defaultOrderFlow = null;
            }

            return orderFlows.Remove(orderFlowName);
        }
        /// <summary>
        /// Remove an <see cref="OrderFlow"/> from the collection
        /// </summary>
        /// <param name="orderFlowName">The name of the <see cref="OrderFlow"/> to remove</param>
        /// <returns>If the <see cref="OrderFlow"/> was removed or not.</returns>
        public bool Remove(string orderFlowName)
        {
            if (defaultOrderFlow != null && defaultOrderFlow.Name == orderFlowName)
            {
                defaultOrderFlow = null;
            }

            return(orderFlows.Remove(orderFlowName));
        }
Esempio n. 4
0
        public static void RegisterOrderFlows(OrderFlowCollection orderFlows)
        {
            var defaultOrderFlow = new OrderFlow("DefaultFlow", new[] { "Domains", "HostingPackage", "Account", "Checkout" });

            // Alias Default to Domains, to match Default route setup. 
            defaultOrderFlow.AddRouteNameAlias("OrderFlowStart", "Domains");

            orderFlows.Add(defaultOrderFlow, true);
        }
        /// <summary>
        /// Get an <see cref="OrderFlow"/> from the collection.
        /// </summary>
        /// <param name="orderFlowName">The name of the <see cref="OrderFlow"/> to get.</param>
        /// <returns>The <see cref="OrderFlow"/> or null if order flow with name is not found</returns>
        public OrderFlow GetOrderFlow(string orderFlowName)
        {
            OrderFlow orderFlow = null;

            if (orderFlows.ContainsKey(orderFlowName))
            {
                orderFlow = orderFlows[orderFlowName];
            }

            return(orderFlow);
        }
        /// <summary>
        /// Add an <see cref="OrderFlow"/> to the collection
        /// </summary>
        /// <param name="orderFlow">The <see cref="OrderFlow"/> to add</param>
        /// <param name="isDefault">If the added order flow should be default or not.</param>
        /// <exception cref="System.InvalidOperationException">If an <see cref="OrderFlow"/> with the same name already exists in the collection</exception>
        /// <exception cref="System.InvalidOperationException">If trying to set order flow as a default in a collection that already has a default order flow.</exception>
        public void Add(OrderFlow orderFlow, bool isDefault)
        {
            if (orderFlows.ContainsKey(orderFlow.Name))
            {
                throw new InvalidOperationException(String.Format("Order flows already contains an order flow name {0}", orderFlow.Name));
            }

            orderFlows.Add(orderFlow.Name, orderFlow);

            if (defaultOrderFlow == null && isDefault)
            {
                defaultOrderFlow = orderFlow;
            }
            else if (isDefault)
            {
                throw new InvalidOperationException("Cannot set more than one default order flow.");
            }
        }
        /// <summary>
        /// Add an <see cref="OrderFlow"/> to the collection
        /// </summary>
        /// <param name="orderFlow">The <see cref="OrderFlow"/> to add</param>
        /// <param name="isDefault">If the added order flow should be default or not.</param>
        /// <exception cref="System.InvalidOperationException">If an <see cref="OrderFlow"/> with the same name already exists in the collection</exception>
        /// <exception cref="System.InvalidOperationException">If trying to set order flow as a default in a collection that already has a default order flow.</exception>
        public void Add(OrderFlow orderFlow, bool isDefault)
        {
            if (orderFlows.ContainsKey(orderFlow.Name))
            {
                throw new InvalidOperationException(String.Format("Order flows already contains an order flow name {0}", orderFlow.Name));
            }

            orderFlows.Add(orderFlow.Name, orderFlow);

            if (defaultOrderFlow == null && isDefault)
            {
                defaultOrderFlow = orderFlow;
            }
            else if (isDefault)
            {
                throw new InvalidOperationException("Cannot set more than one default order flow.");
            }
        }
 /// <summary>
 /// Remove all <see cref="OrderFlow">OrderFlows</see> from the collection.
 /// </summary>
 public void Clear()
 {
     defaultOrderFlow = null;
     orderFlows.Clear();
 }
 /// <summary>
 /// Add an <see cref="OrderFlow"/> to the collection
 /// </summary>
 /// <param name="orderFlow">The <see cref="OrderFlow"/> to add</param>
 /// <exception cref="System.InvalidOperationException">If an <see cref="OrderFlow"/> with the same name already exists in the collection</exception>
 public void Add(OrderFlow orderFlow)
 {
     this.Add(orderFlow, false);
 }
 /// <summary>
 /// Remove all <see cref="OrderFlow">OrderFlows</see> from the collection.
 /// </summary>
 public void Clear()
 {
     defaultOrderFlow = null;
     orderFlows.Clear();
 }
 /// <summary>
 /// Add an <see cref="OrderFlow"/> to the collection
 /// </summary>
 /// <param name="orderFlow">The <see cref="OrderFlow"/> to add</param>
 /// <exception cref="System.InvalidOperationException">If an <see cref="OrderFlow"/> with the same name already exists in the collection</exception>
 public void Add(OrderFlow orderFlow)
 {
     this.Add(orderFlow, false);
 }
Esempio n. 12
0
        /// <summary>
        /// Validates <see cref="Atomia.Store.AspNetMvc.Models.OrderFlowModel"/> for current step.
        /// </summary>
        private void ValidateOrderFlowStep(ActionExecutingContext filterContext, OrderFlow orderFlow, OrderFlowStep currentOrderFlowStep)
        {
            var orderFlowValidator = DependencyResolver.Current.GetService<IOrderFlowValidator>();

            var validationMessages = orderFlowValidator.ValidateOrderFlowStep(orderFlow, currentOrderFlowStep);

            if (validationMessages.Count() > 0)
            {
                // TODO: Make messages available to next controller via flash message provider
                filterContext.Result = new RedirectToRouteResult(currentOrderFlowStep.Previous, new RouteValueDictionary());
            }
        }