Ejemplo n.º 1
0
        public string GetViewName(JourneyViewModel model, ControllerContext context)
        {
            if (model == null)
            {
                return("../Question/Question");
            }

            switch (model.NodeType)
            {
            case NodeType.Outcome:
                var viewFilePath = "../Outcome/" + model.OutcomeGroup.Id;
                //if (model.OutcomeGroup.IsPostcodeFirst())
                //{
                //    model.UserInfo.CurrentAddress.IsPostcodeFirst = true;
                //    _auditLogger.LogEventData(model, "Postcode first journey started");

                //    viewFilePath = "../PostcodeFirst/Postcode";
                // }

                if (ViewExists(viewFilePath, context))
                {
                    _userZoomDataBuilder.SetFieldsForOutcome(model);
                    return(viewFilePath);
                }
                throw new ArgumentOutOfRangeException(string.Format("Outcome group {0} for outcome {1} has no view configured", model.OutcomeGroup.ToString(), model.Id));

            case NodeType.DeadEndJump:
                _userZoomDataBuilder.SetFieldsForOutcome(model);
                return("../Outcome/DeadEndJump");

            case NodeType.PathwaySelectionJump:
                _userZoomDataBuilder.SetFieldsForOutcome(model);
                return("../Outcome/PathwaySelectionJump");

            case NodeType.CareAdvice:
                _userZoomDataBuilder.SetFieldsForCareAdvice(model);
                return("../Question/InlineCareAdvice");

            case NodeType.Question:
            default:
                _userZoomDataBuilder.SetFieldsForQuestion(model);
                return("../Question/Question");
            }
        }
        public JourneyResultViewModel Build(JourneyViewModel journeyViewModel, ControllerContext context)
        {
            if (journeyViewModel == null)
            {
                return(new QuestionResultViewModel(journeyViewModel));
            }

            switch (journeyViewModel.NodeType)
            {
            case NodeType.Outcome:

                if (journeyViewModel.OutcomeGroup.Id == "111_Search_Jump")
                {
                    // This outcome is used to go from mid-pathway into search
                    return(new SearchJumpViewModel(journeyViewModel));
                }

                if (journeyViewModel.OutcomeGroup.IsVerifySMS)
                {
                    return(new VerifyForSMSViewModel(journeyViewModel));
                }

                if (journeyViewModel.OutcomeGroup.IsSendSMS)
                {
                    return(new RegisterForSMSViewModel(journeyViewModel));
                }

                var outcomeViewModel = journeyViewModel as OutcomeViewModel;
                var result           = new OutcomeResultViewModel(outcomeViewModel, IsTestJourney(outcomeViewModel));
                if (ViewExists(result.ViewName, context))
                {
                    _userZoomDataBuilder.SetFieldsForOutcome(journeyViewModel);
                    return(result);
                }
                throw new ArgumentOutOfRangeException(string.Format("Outcome group {0} for outcome {1} has no view configured", outcomeViewModel.OutcomeGroup.Id, outcomeViewModel.Id));

            case NodeType.DeadEndJump:
                _userZoomDataBuilder.SetFieldsForOutcome(journeyViewModel);
                return(new DeadEndJumpResultViewModel(journeyViewModel));

            case NodeType.PathwaySelectionJump:
                _userZoomDataBuilder.SetFieldsForOutcome(journeyViewModel);
                return(new PathwaySelectionJumpResultViewModel(journeyViewModel));

            case NodeType.CareAdvice:
                _userZoomDataBuilder.SetFieldsForCareAdvice(journeyViewModel);
                return(new CareAdviceResultViewModel(journeyViewModel));

            case NodeType.Page:
                if (journeyViewModel.Content != null && journeyViewModel.Content.StartsWith("!CustomView!"))
                {
                    return(new PageResultViewModel(journeyViewModel, String.Format("../Question/Custom/{0}", journeyViewModel.Content.Replace("!CustomView!", ""))));
                }

                return(new PageResultViewModel(journeyViewModel));

            case NodeType.NotFound:
                return(new NodeNotFoundViewModel(journeyViewModel));

            default:
                _userZoomDataBuilder.SetFieldsForQuestion(journeyViewModel);
                return(new QuestionResultViewModel(journeyViewModel));
            }
        }