コード例 #1
0
        public async Task<Tuple<string, JourneyViewModel>> BuildNextAction(List<QuestionWithAnswers> questions, Journey journey, JustToBeSafeViewModel model, Answer selectedAnswer, QuestionWithAnswers selectedQuestion, string questionsJson)
        {
            if (!questions.Any())
            {
                journey.Steps = journey.Steps.Where(step => step.QuestionId != model.SelectedQuestionId).ToList();
                var journeyViewModel = new JourneyViewModel
                {
                    PathwayId = model.PathwayId,
                    PathwayNo = model.PathwayNo,
                    PathwayTitle = model.PathwayTitle,
                    SymptomDiscriminator = model.SymptomDiscriminator,
                    UserInfo = model.UserInfo,
                    JourneyJson = JsonConvert.SerializeObject(journey),
                    SelectedAnswer = JsonConvert.SerializeObject(selectedAnswer),
                };

                _mappingEngine.Map(selectedQuestion, journeyViewModel);
                journeyViewModel = _mappingEngine.Map(selectedAnswer, journeyViewModel);
                
                return await _questionViewModelBuilder.BuildQuestion(journeyViewModel);
            }

            if (questions.Count() == 1)
            {
                var journeyViewModel = new JourneyViewModel
                {
                    PathwayId = model.PathwayId,
                    PathwayNo = model.PathwayNo,
                    PathwayTitle = model.PathwayTitle,
                    UserInfo = model.UserInfo,
                    JourneyJson = JsonConvert.SerializeObject(journey),
                };

                _mappingEngine.Map(questions.First(), journeyViewModel);
                journeyViewModel = _mappingEngine.Map(selectedAnswer, journeyViewModel);

                return new Tuple<string, JourneyViewModel>("../Question/Question", journeyViewModel);
            }

            var viewModel = new JustToBeSafeViewModel
            {
                PathwayId = model.PathwayId,
                PathwayNo = model.PathwayNo,
                PathwayTitle = model.PathwayTitle,
                JourneyJson = JsonConvert.SerializeObject(journey),
                SymptomDiscriminator = selectedAnswer.SymptomDiscriminator ?? model.SymptomDiscriminator,
                Part = model.Part + 1,
                Questions = questions,
                QuestionsJson = questionsJson,
                UserInfo = model.UserInfo
            };

            return new Tuple<string, JourneyViewModel>("JustToBeSafe", viewModel);

        }
コード例 #2
0
 public Journey Add(Journey otherJourney)
 {
     otherJourney.Steps.ForEach(step => Steps.Add(step));
     return this;
 }
コード例 #3
0
ファイル: Journey.cs プロジェクト: eiki25/nhs111-dotnet-beta
 public Journey Add(Journey otherJourney)
 {
     otherJourney.Steps.ForEach(step => Steps.Add(step));
     return(this);
 }