private async Task OnDeliverySelected(IDialogContext context, IAwaitable <IEnumerable <DateTime> > result) { try { // "result" contains the date (or array of dates) returned from the prompt var momentOrRange = await result; var quantity = context.ConversationData.GetValue <int>("quantity"); var quantityRoses = quantity == 1 ? "Just one rose" : $"{quantity} roses"; var text = $"Thank you! I'll deliver {quantityRoses} {DeliveryPrompt.MomentOrRangeToString(momentOrRange)}."; await context.PostAsync(text); // TODO: It should continue to a checkout dialog or page await context.PostAsync("Have a nice day!"); } catch (TooManyAttemptsException) { await context.PostAsync("Restarting now..."); } finally { context.Wait(this.MessageReceivedAsync); } }
private async Task OnQuantitySelected(IDialogContext context, IAwaitable <int> result) { try { var quantity = await result; var quantityMessage = quantity == 1 ? "I'll send just one rose." : $"I'll send {quantity} roses."; await context.PostAsync(quantityMessage); // Store amount context.ConversationData.SetValue("quantity", quantity); // Prompt for delivery date var prompt = new DeliveryPrompt(GetCurrentCultureCode()); context.Call(prompt, this.OnDeliverySelected); } catch (TooManyAttemptsException) { await context.PostAsync("Restarting now..."); context.Wait(this.MessageReceivedAsync); } }