private async Task <DialogTurnResult> ShowTasksStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { List <ToDoTask> toDoTasks = await _cosmosDBClient.QueryItemsAsync(User.UserID); if (toDoTasks.Count == 0) { await stepContext.Context.SendActivityAsync(MessageFactory.Text("You don't have any tasks to delete."), cancellationToken); return(await stepContext.EndDialogAsync(null, cancellationToken)); } List <string> taskList = new List <string>(); for (int i = 0; i < toDoTasks.Count; i++) { taskList.Add(toDoTasks[i].Task); } await stepContext.Context.SendActivityAsync(MessageFactory.Text("Please select the tasks you want to delete."), cancellationToken); var card = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0)) { // Use LINQ to turn the choices into submit actions Actions = taskList.Select(choice => new AdaptiveSubmitAction { Title = choice, Data = choice, // This will be a string }).ToList <AdaptiveAction>(), }; // Prompt return(await stepContext.PromptAsync(nameof(ChoicePrompt), new PromptOptions { Prompt = (Activity)MessageFactory.Attachment(new Attachment { ContentType = AdaptiveCard.ContentType, // Convert the AdaptiveCard to a JObject Content = JObject.FromObject(card), }), Choices = ChoiceFactory.ToChoices(taskList), // Don't render the choices outside the card Style = ListStyle.None, }, cancellationToken)); }
private async Task <DialogTurnResult> ShowTasksStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { List <ToDoTask> toDoTasks = await _cosmosDBClient.QueryItemsAsync(User.UserID, Configuration["CosmosEndPointURI"], Configuration["CosmosPrimaryKey"], Configuration["CosmosDatabaseId"], Configuration["CosmosContainerID"], Configuration["CosmosPartitionKey"]); if (toDoTasks.Count == 0) { await stepContext.Context.SendActivityAsync(MessageFactory.Text("You don't have any tasks added."), cancellationToken); return(await stepContext.EndDialogAsync(null, cancellationToken)); } await stepContext.Context.SendActivityAsync(MessageFactory.Text("Please find the below tasks you provided."), cancellationToken); for (int i = 0; i < toDoTasks.Count; i++) { await stepContext.Context.SendActivityAsync(MessageFactory.Text(toDoTasks[i].Task), cancellationToken); } return(await stepContext.EndDialogAsync(null, cancellationToken)); }