Example #1
0
        private async Task FillAnOrder(ConversationFlow flow, OrderInfo profile, ITurnContext <IMessageActivity> turnContext)
        {
            string input = turnContext.Activity.Text?.Trim();
            string message;

            switch (flow.LastQuestionAsked)
            {
            case ConversationFlow.Question.None:
                await turnContext.SendActivityAsync("Let's get started. What is your name?");

                flow.LastQuestionAsked = ConversationFlow.Question.Name;
                break;

            case ConversationFlow.Question.Name:
                if (OrderValidation.ValidateName(input, out string name, out message))
                {
                    profile.Name = name;
                    await turnContext.SendActivityAsync($"Hi {profile.Name}.");

                    await turnContext.SendActivityAsync("How old are you?");

                    flow.LastQuestionAsked = ConversationFlow.Question.Age;
                    break;
                }
                else
                {
                    await turnContext.SendActivityAsync(message ?? "I'm sorry, I didn't understand that.");

                    break;
                }