/// <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> /// 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()); } }