Esempio n. 1
0
        /// <summary>
        /// Generates new QuestionAndAnswerModel and returns ChoicePrompt
        /// or passes on not modified QuestionAndAnswerModel to the next step.
        /// </summary>
        /// <param name="stepContext"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        private async Task <DialogTurnResult> GetCountryStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var _DialogInfo = await _dialogInfoStateProperty.GetAsync(stepContext.Context);

            _DialogInfo.LastDialogName = this.Id;
            var _country = new Country();



            {
                var _countries = DecisionMaker.GetCountries(_DialogInfo.Language);
                var choices    = new List <Choice>();

                foreach (var country in _countries)
                {
                    choices.Add(new Choice(country.CountryName));
                }

                var dialogsMUI = DecisionMaker.GetDialogsMui(_DialogInfo.Language);

                var prompt   = dialogsMUI.LocationDictionary["promptCountry"]; // "Choose needed country, please.";
                var reprompt = dialogsMUI.MainDictionary["reprompt"];          // "Try one more time, please:";

                var options = new PromptOptions()
                {
                    Prompt      = MessageFactory.Text(prompt),
                    RetryPrompt = MessageFactory.Text(reprompt),
                    Choices     = choices,
                    Style       = ListStyle.SuggestedAction
                };

                var message = options.Prompt.Text;
                var sender  = "bot";
                var time    = stepContext.Context.Activity.Timestamp.Value;

                _myLogger.LogMessage(message, sender, time, _DialogInfo.DialogId);

                //await _dialogInfoStateProperty.SetAsync(stepContext.Context, _DialogInfo);

                return(await stepContext.PromptAsync(nameof(ChoicePrompt), options, cancellationToken));
            }
        }