コード例 #1
0
        public async Task QuizMessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            try
            {
                var activity = await result as Activity;

                if (activity == null)
                {
                    activity = context.Activity as Activity;
                }

                ConnectDB connect = new ConnectDB();
                await connect.CreateDocumentIfNotExists("Message", activity);

                await connect.SaveMessage("Message", activity);

                if (_db.ConversationStatus == (int)QuizEnum.Init)
                {
                    await ConversationInit(activity, context);
                }
                else if (_db.ConversationStatus == (int)QuizEnum.Pergunta1)
                {
                    await ConversationPergunta1(activity, context);
                }
                else if (_db.ConversationStatus == (int)QuizEnum.Pergunta2)
                {
                    await ConversationPergunta2(activity, context);
                }
                else if (_db.ConversationStatus == (int)QuizEnum.Pergunta3)
                {
                    await ConversationPergunta3(activity, context);
                }
                else if (_db.ConversationStatus == (int)QuizEnum.Pergunta4)
                {
                    await ConversationPergunta4(activity, context);
                }
                else if (_db.ConversationStatus == (int)QuizEnum.Pergunta5)
                {
                    await ConversationPergunta5(activity, context);
                }
                else if (_db.ConversationStatus == (int)QuizEnum.Pergunta6)
                {
                    await ConversationPergunta6(activity, context);
                }
                else if (_db.ConversationStatus == (int)QuizEnum.Pergunta7)
                {
                    await ConversationPergunta7(activity, context);
                }
                else if (_db.ConversationStatus == (int)QuizEnum.Pergunta8)
                {
                    await ConversationPergunta8(activity, context);
                }
                else if (_db.ConversationStatus == (int)QuizEnum.Pergunta9)
                {
                    await ConversationPergunta9(activity, context);
                }
                else if (_db.ConversationStatus == (int)QuizEnum.Pergunta10)
                {
                    await ConversationFinal(activity, context);
                }
                else if (_db.ConversationStatus == (int)QuizEnum.Fim)
                {
                    await ConversationConclusao(activity, context);
                }
            }
            catch (Exception ex)
            {
                context.Done(new ResultDialog {
                    Activity = context.Activity as Activity
                });
            }
        }