示例#1
0
        public void GetStockApple()
        {
            string _stockCode = "AAPL.US";
            string _respuesta = new ChatJobsity.App_Code.StockProvider().GetStock(_stockCode);
            string _getCodigo = _respuesta.Split(',')[0];

            Assert.AreEqual(_stockCode, _getCodigo);
        }
示例#2
0
        public void Send(string _message)
        {
            if (!_message.Contains("/stock="))
            {
                var sender = ConnectedClients.First(x => x.Id.Equals(Context.ConnectionId));
                Clients.All.SendData(System.DateTime.UtcNow.AddHours(-5).ToString("yyyy-MM-dd HH:mm:ss") + " - " + sender.UserName, _message);
            }
            else
            {
                string _stockCode = _message.Split(new string[] { "/stock=" }, StringSplitOptions.None)[1];
                string _respuesta = new ChatJobsity.App_Code.StockProvider().GetStock(_stockCode);

                if (_respuesta.Split(',')[1] == "N/D")
                {
                    Clients.All.SendData(System.DateTime.UtcNow.AddHours(-5).ToString("yyyy-MM-dd HH:mm:ss") + " - Bot Stock", "the code of stock is not correct");
                }
                else
                {
                    string[] _dataStock = _respuesta.Split(',');
                    Clients.All.SendData(System.DateTime.UtcNow.AddHours(-5).ToString("yyyy-MM-dd HH:mm:ss") + " - Bot Stock", String.Format("{0} quote is ${1} per share", _dataStock[0], _dataStock[3]));
                }
            }
        }