public static IForm <OrderDetails> BuildForm() { var menuItems = MenuDB.GetAllMenuOptions(); var builder = new FormBuilder <OrderDetails>(); builder .Message("Welcome to demo Restaurant bot!") .Field(new FieldReflector <OrderDetails>(nameof(MenuItems)) .SetType(null) .SetDefine((state, field) => { foreach (var item in menuItems) { field .AddDescription(item, item.ItemName) .AddTerms(item, item.ItemName); } return(Task.FromResult(true)); })) .AddRemainingFields() .OnCompletion(async(context, order) => { await context.PostAsync("Thanks for your order!"); }); return(builder.Build()); }
public static IForm <OrderDetails> BuildForm() { var menuItems = MenuDB.GetAllMenuOptions(); var builder = new FormBuilder <OrderDetails>(); builder .Message("Welcome to Restaurant bot!") .Field(new FieldReflector <OrderDetails>(nameof(MenuItems)) .SetType(null) .SetFieldDescription("Menu items") .SetDefine((state, field) => { foreach (var item in menuItems) { field .AddDescription(item, new DescribeAttribute(title: item.ItemName, description: item.ItemName, subTitle: item.Description, image: item.ItemImage)) .AddTerms(item, item.ItemName); } return(Task.FromResult(true)); }) .SetPrompt(new PromptAttribute("Select from the {&} \n {||} \n") { ChoiceStyle = ChoiceStyleOptions.Auto }) .SetAllowsMultiple(false) ) .AddRemainingFields() .Confirm(async(state) => { return(new PromptAttribute("Hi {UserName}.you choose {Totalno} of {MenuItems.ItemName}? {||}")); }) .OnCompletion(async(context, order) => { await context.PostAsync("Thanks for your order!"); }); return(builder.Build()); }