示例#1
0
        private async Task <DialogTurnResult> ShowChoiceDialog(WaterfallStepContext stepContext,
                                                               CancellationToken cancellationToken)
        {
            var userId = new UserId(stepContext.Context.Activity);

            var notCompletedScenarioNames = await _scenarioService.GetNotCompletedScenarioNames(userId);

            if (notCompletedScenarioNames.Any())
            {
                var reply = MessageFactory.Text($"Доступныx сценариев ({notCompletedScenarioNames.Count}):");


                reply.SuggestedActions = new SuggestedActions()
                {
                    Actions = notCompletedScenarioNames
                              .Select(name => new CardAction()
                    {
                        Title = name, Type = ActionTypes.ImBack, Value = name
                    })
                              .ToList()
                };

                await stepContext.Context.SendActivityAsync(reply, cancellationToken);

                return(new DialogTurnResult(DialogTurnStatus.Waiting));
            }
            else
            {
                await stepContext.Context.SendActivityAsync("Поздравляем! Вы прошли все сценарии",
                                                            cancellationToken : cancellationToken);

                return(await stepContext.EndDialogAsync(null, cancellationToken));
            }
        }