public static async Task <string> GetStock(string strStock) { string strRet = string.Empty; double?dblStock = await Yahoo.GetStockPriceAsync(strStock); if (null == dblStock) // might be a company name rather than a stock ticker name { string strTicker = await GetStockTickerName(strStock); if (string.Empty != strTicker) { dblStock = await Yahoo.GetStockPriceAsync(strTicker); strStock = strTicker; } } // return our reply to the user if (null == dblStock) { strRet = string.Format("Stock {0} doesn't appear to be valid", strStock.ToUpper()); } else { strRet = string.Format("Stock: {0}, Value: {1}", strStock.ToUpper(), dblStock); } return(strRet); }
public async Task StockPrice(IDialogContext context, LuisResult result) { string strRet = result.Entities[0].Entity; //store this stock for the conversation context.ConversationData.SetValue <string>("LastStock", strRet); await context.PostAsync(await Yahoo.GetStock(strRet)); context.Wait(MessageReceived); }
public async Task RepeatLastStock(IDialogContext context, LuisResult result) { string strRet = string.Empty; string strStock = string.Empty; if (!context.ConversationData.TryGetValue("LastStock", out strStock)) { strRet = "I don't have a previous stock to look up!"; } else { strRet = await Yahoo.GetStock(strStock); } await context.PostAsync(strRet); context.Wait(MessageReceived); }