Esempio n. 1
0
        public async Task <IActionResult> ExpandedCoin(string symbol = "DOGE")
        {
            await AddCoinInfoToDatabase(symbol);

            var userId = _userManager.GetUserId(User);
            var model  = new ExpandedCoinViewModel();

            model.RedditPosts = await SearchReddit(symbol);

            model.AllInfo = await GetAllCoinInfo();

            model.DatabaseInfo = GetCoinInfoFromDatabase(symbol);
            var tempObject = await SearchBySymbolExact(symbol);

            var wallet = GetWalletFromDatabase(symbol);

            model.CoinSymbol         = tempObject.CoinSymbol;
            model.Price              = tempObject.Price;
            model.PriceChange        = tempObject.PriceChange;
            model.PriceChangePercent = tempObject.PriceChangePercent;
            model.Count              = tempObject.Count;
            model.Lables             = new List <string>();
            model.Data = new List <float>();
            double datbaseDividedByFive = (model.DatabaseInfo.Count() / 5);
            var    iter        = (int)Math.Truncate(datbaseDividedByFive);
            var    easternZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");

            for (int i = model.DatabaseInfo.Count - 1; i >= iter - 1; i = i - iter)
            {
                model.Lables.Add(model.DatabaseInfo[i].EntryTime.ToLocalTime().ToString());
                model.Data.Add(model.DatabaseInfo[i].Price);
            }
            if (wallet != null)
            {
                model.IsinWallet = true;
                model.UserHigh   = wallet.UserHigh;
                model.UserLow    = wallet.UserLow;
            }
            else
            {
                model.IsinWallet = false;
                model.UserHigh   = 0;
                model.UserLow    = 0;
            }

            return(View(model));
        }
        public async Task <IActionResult> ExpandedCoin(string symbol = "DOGE")
        {
            var userId = _userManager.GetUserId(User);
            var model  = new ExpandedCoinViewModel();

            model.RedditPosts = await SearchReddit(symbol);

            model.AllInfo = await GetAllCoinInfo();

            model.DatabaseInfo = GetCoinInfoFromDatabase(symbol);
            var tempObject = await SearchBySymbolExact(symbol);

            var wallet = GetWalletFromDatabase(symbol);

            model.CoinSymbol         = tempObject.CoinSymbol;
            model.Price              = tempObject.Price;
            model.PriceChange        = tempObject.PriceChange;
            model.PriceChangePercent = tempObject.PriceChangePercent;
            model.Count              = tempObject.Count;
            model.Lables             = new List <string>();
            model.Data = new List <float>();
            for (int i = 0; i < model.DatabaseInfo.Count; i++)
            {
                model.Lables.Add(model.DatabaseInfo[i].EntryTime.ToString());
                model.Data.Add(model.DatabaseInfo[i].Price);
            }
            if (wallet != null)
            {
                model.IsinWallet = true;
                model.UserHigh   = wallet.UserHigh;
                model.UserLow    = wallet.UserLow;
            }
            else
            {
                model.IsinWallet = false;
                model.UserHigh   = 0;
                model.UserLow    = 0;
            }

            return(View(model));
        }