示例#1
0
        private async Task HandleConfirm(IDialogContext context, IAwaitable <bool> result)
        {
            bool selectedOption = await result;

            if (selectedOption)
            {
                currentTrivia = await TriviaService.GetTrivia();

                await context.PostAsync("Category: " + currentTrivia.category);

                await context.PostAsync("Difficulty: " + currentTrivia.difficulty);

                List <string> answers = new List <string>();

                answers.AddRange(currentTrivia.incorrect_answers);

                int randomIndex = new Random().Next(answers.Count);
                answers.Insert(randomIndex, currentTrivia.correct_answer);

                PromptDialog.Choice <string>(context, HandleAnswerChoice, answers, currentTrivia.question);
            }
            else
            {
                await context.PostAsync("OK... Maybe next time.");
            }
        }
        public Trivia Get(int id)
        {
            var trivia = _triviaService.GetTrivia(id);

            return(MapTriviaToViewModel(trivia));
        }