async Task DoSearch(IDialogContext context, WineForm wineInfo) { int wineType = (from refinement in WineCategories where refinement.Name == wineInfo.WineType select refinement.Id) .SingleOrDefault(); List[] wines = await new WineApi().SearchAsync( wineType, wineInfo.Rating, wineInfo.InStock == StockingType.InStock, wineInfo.SearchTerms); string message; if (wines.Any()) { message = "Here are the top matching wines: " + string.Join(", ", wines.Select(w => w.Name)); } else { message = "Sorry, No wines found matching your criteria."; } await context.PostAsync(message); context.EndConversation(EndOfConversationCodes.CompletedSuccessfully); }
async Task <IDialog <WineForm> > BuildWineDialogAsync() { if (wineCategories == null) { wineCategories = await new WineApi().GetWineCategoriesAsync(); } var wineForm = new WineForm { WineCategories = wineCategories, InStock = StockingType.InStock, Rating = 75, Vintage = 2010 }; return(new FormDialog <WineForm>( wineForm, wineForm.BuildForm, FormOptions.PromptFieldsWithValues)); }