public Task Menu(IDialogContext dialogContext, LuisResult luisResult) { var dialog = FormDialog.FromForm(Restaurant_bot__BSc_Thesis_.Menu.BuildForm, options: FormOptions.PromptInStart); dialogContext.Call(dialog, async(context, result) => { try { var menuOrder = await result; var status = context.MakeMessage(); status.Type = ActivityTypes.Message; List <ReceiptItem> receiptList = new List <ReceiptItem>(); ReceiptItem lineItem1 = new ReceiptItem() { Title = UiFriendlyString.GetMenu(menuOrder.menu) + " that contains:" }; receiptList.Add(lineItem1); if (menuOrder.menu == Menus.KidsMenu) { ReceiptItem lineItem2 = new ReceiptItem() { Title = UiFriendlyString.GetMeal(Meals.Hamburger) }; receiptList.Add(lineItem2); } else if (menuOrder.menu == Menus.OriginalMenu) { ReceiptItem lineItem2 = new ReceiptItem() { Title = UiFriendlyString.GetMeal(Meals.Cheeseburger) }; receiptList.Add(lineItem2); } else if (menuOrder.menu == Menus.VegetarianMenu) { ReceiptItem lineItem2 = new ReceiptItem() { Title = UiFriendlyString.GetMeal(Meals.VeggieBurger) }; receiptList.Add(lineItem2); } if (menuOrder.menu == Menus.KidsMenu) { ReceiptItem lineItem3 = new ReceiptItem() { Title = UiFriendlyString.GetSnack(SaladsAndSnacks.OnionRings) }; receiptList.Add(lineItem3); } else if (menuOrder.menu == Menus.OriginalMenu) { ReceiptItem lineItem3 = new ReceiptItem() { Title = UiFriendlyString.GetSnack(SaladsAndSnacks.PotatoFries) }; receiptList.Add(lineItem3); } else if (menuOrder.menu == Menus.VegetarianMenu) { ReceiptItem lineItem3 = new ReceiptItem() { Title = UiFriendlyString.GetSnack(SaladsAndSnacks.Veggies) }; receiptList.Add(lineItem3); } if (menuOrder.menu == Menus.KidsMenu) { ReceiptItem lineItem4 = new ReceiptItem() { Title = UiFriendlyString.GetDrinks(Drinks.AppleJuice) }; receiptList.Add(lineItem4); } else if (menuOrder.menu == Menus.OriginalMenu) { ReceiptItem lineItem4 = new ReceiptItem() { Title = UiFriendlyString.GetDrinks(Drinks.CokeSoda) }; receiptList.Add(lineItem4); } else if (menuOrder.menu == Menus.VegetarianMenu) { ReceiptItem lineItem4 = new ReceiptItem() { Title = UiFriendlyString.GetDrinks(Drinks.OrangeJuice) }; receiptList.Add(lineItem4); } ReceiptItem lineItem5 = new ReceiptItem() { Title = "Discount worth 15% for ordering menu" }; receiptList.Add(lineItem5); ReceiptCard plCard = new ReceiptCard() { Title = "Thanks for placing order. Your order is: ", Items = receiptList, //if DB is added, add code here }; Attachment plAttachment = plCard.ToAttachment(); status.Attachments.Add(plAttachment); await context.PostAsync(status); } catch (FormCanceledException <Menu> ex) { string reply; if (ex.InnerException == null) { reply = $"You quit on {ex.Last} -- maybe you can finish next time!"; } else { reply = $"Sorry, I've had a short circuit. Please try again.{ex.StackTrace}"; } await context.PostAsync(reply); } context.Wait(MessageReceived); }); return(Task.CompletedTask); }
public async Task Dessert(IDialogContext dialogContext, LuisResult luisResult) { Order state = new Order(); state.Meals = Meals.None;//not needed state.SaladsAndSnacks = SaladsAndSnacks.None; var dialog = new FormDialog <Order>(state, Order.BuildForm, FormOptions.PromptInStart); dialogContext.Call(dialog, async(context, result) => { try { var order = await result; var status = context.MakeMessage(); status.Type = ActivityTypes.Message; List <ReceiptItem> receiptList = new List <ReceiptItem>(); ReceiptItem lineItem1 = new ReceiptItem() { Title = UiFriendlyString.GetMeal(order.Meals) }; if (lineItem1.Title != "") { receiptList.Add(lineItem1); } if (order.SaladsAndSnacks != 0) { ReceiptItem lineItem2 = new ReceiptItem() { Title = UiFriendlyString.GetSnack(order.SaladsAndSnacks) }; if (lineItem2.Title != "") { receiptList.Add(lineItem2); } } if (order.Drinks != 0) { ReceiptItem lineItem3 = new ReceiptItem() { Title = UiFriendlyString.GetDrinks(order.Drinks) }; if (lineItem3.Title != "") { receiptList.Add(lineItem3); } } if (order.Desserts != 0) { ReceiptItem lineItem4 = new ReceiptItem() { Title = UiFriendlyString.GetDessert(order.Desserts) }; if (lineItem4.Title != "") { receiptList.Add(lineItem4); } } if (order.Meals == Meals.Cheeseburger && order.Drinks == Drinks.CokeSoda && order.SaladsAndSnacks == SaladsAndSnacks.PotatoFries) { ReceiptItem lineItem5 = new ReceiptItem() { Title = "Discount worth 15%" }; receiptList.Add(lineItem5); } ReceiptCard plCard = new ReceiptCard() { Title = "Thanks for placing order. Your order is: ", Items = receiptList, //if DB is added, add code here }; Attachment plAttachment = plCard.ToAttachment(); status.Attachments.Add(plAttachment); await context.PostAsync(status); } catch (FormCanceledException <Order> ex) { string reply; if (ex.InnerException == null) { reply = $"You quit on {ex.Last} -- maybe you can finish next time!"; } else { reply = $"Sorry, I've had a short circuit. Please try again.{ex.StackTrace}"; } await context.PostAsync(reply); } context.Wait(MessageReceived); }); }