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 questionViewModel = new QuestionViewModel { PathwayId = model.PathwayId, PathwayNo = model.PathwayNo, PathwayTitle = model.PathwayTitle, SymptomDiscriminatorCode = model.SymptomDiscriminatorCode, UserInfo = model.UserInfo, JourneyJson = JsonConvert.SerializeObject(journey), SelectedAnswer = JsonConvert.SerializeObject(selectedAnswer), }; _mappingEngine.Mapper.Map(selectedQuestion, questionViewModel); questionViewModel = _mappingEngine.Mapper.Map(selectedAnswer, questionViewModel); var nextNode = await GetNextNode(questionViewModel); return(new Tuple <string, JourneyViewModel>("TODO NOT USED?", await _journeyViewModelBuilder.Build(questionViewModel, nextNode))); } 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.Mapper.Map(questions.First(), journeyViewModel); journeyViewModel = _mappingEngine.Mapper.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), SymptomDiscriminatorCode = selectedAnswer.SymptomDiscriminator ?? model.SymptomDiscriminatorCode, Part = model.Part + 1, Questions = questions, QuestionsJson = questionsJson, UserInfo = model.UserInfo }; return(new Tuple <string, JourneyViewModel>("JustToBeSafe", viewModel)); }
public async Task <JourneyViewModel> GetNextJourneyViewModel(QuestionViewModel model) { var nextNode = await GetNextNode(model).ConfigureAwait(false); return(await _journeyViewModelBuilder.Build(model, nextNode).ConfigureAwait(false)); }