Esempio n. 1
0
        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);
        }