Esempio n. 1
0
        public async Task <ActionResult> GetStockQuote(string symbol)
        {
            ApiHelper.InitializeClient();

            Stock stockQuote = await _stockFactory.LoadStock(symbol);

            return(Ok(stockQuote));
        }
Esempio n. 2
0
        public ActionResult AuthenticateUser(User user)
        {
            var userFound = _userRepo.LoginUser(user.Username, user.Password);

            if (userFound != null)
            {
                //create a tempstocklist to hold information while the original stocklist is iterated over
                var tempStockList = new List <Stock>();

                //iterate over the stocklist to get the most recent stock info, putting the new info in tempStockList
                ApiHelper.InitializeClient();

                foreach (var stock in userFound.Stocks)
                {
                    var s = _stockFactory.LoadStock(stock.Symbol).GetAwaiter().GetResult();
                    tempStockList.Add(s);
                }

                userFound.Stocks = tempStockList;
            }

            return(Ok(user));
        }