public static async Task <IList <CurrencyInfo> > GetTop10(CurrencyEnum selectedCurrency)
        {
            IList <CurrencyInfo> inBitcoinInfo = GetTop10BasedOnCurrency(CurrencyEnum.bitcoin).Result;
            IList <CurrencyInfo> inUSDInfo     = GetTop10BasedOnCurrency(CurrencyEnum.dollars).Result;
            IList <CurrencyInfo> inEURInfo     = GetTop10BasedOnCurrency(CurrencyEnum.euros).Result;

            foreach (CurrencyInfo currI in inBitcoinInfo)
            {
                CurrencyQuote cq  = ((CurrencyQuote)inUSDInfo.Where(x => x.Name == currI.Name).FirstOrDefault().Quotes.FirstOrDefault());
                CurrencyQuote cq2 = ((CurrencyQuote)inEURInfo.Where(x => x.Name == currI.Name).FirstOrDefault().Quotes.FirstOrDefault());
                currI.Quotes.Add(cq);
                currI.Quotes.Add(cq2);
            }

            return(inBitcoinInfo);
        }
        private static async Task <IList <CurrencyInfo> > GetTop10BasedOnCurrency(CurrencyEnum selectedCurrency)
        {
            //var URL = new UriBuilder("https://sandbox-api.coinmarketcap.com/v1/cryptocurrency/listings/latest");
            var URL = new UriBuilder("https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest");

            var queryString = HttpUtility.ParseQueryString(string.Empty);

            queryString["start"]   = "1";
            queryString["limit"]   = "10";
            queryString["sort"]    = "market_cap";
            queryString["convert"] = returnString(selectedCurrency);

            URL.Query = queryString.ToString();

            var client = new WebClient();

            client.Headers.Add("X-CMC_PRO_API_KEY", API_KEY);
            client.Headers.Add("Accepts", "application/json");
            string  returned = client.DownloadString(URL.ToString());
            JObject obj      = JObject.Parse(returned);
            //cathpart where data starts
            IList <JToken>       jsonData             = obj["data"].Children().ToList();
            IList <CurrencyInfo> currencyInfoToReturn = new List <CurrencyInfo>();

            foreach (JToken tokensFromJsonData in jsonData)
            {
                CurrencyInfo CurrencyInfoToReturn = new CurrencyInfo();
                CurrencyInfoToReturn.Id          = (int)tokensFromJsonData.Children().Select(x => x as JProperty).Where(y => y.Name == "id").FirstOrDefault();
                CurrencyInfoToReturn.CmcRank     = (int)tokensFromJsonData.Children().Select(x => x as JProperty).Where(y => y.Name == "cmc_rank").FirstOrDefault();
                CurrencyInfoToReturn.Name        = (string)tokensFromJsonData.Children().Select(x => x as JProperty).Where(y => y.Name == "name").FirstOrDefault();
                CurrencyInfoToReturn.Symbol      = (string)tokensFromJsonData.Children().Select(x => x as JProperty).Where(y => y.Name == "symbol").FirstOrDefault();
                CurrencyInfoToReturn.marketPairs = (long)tokensFromJsonData.Children().Select(x => x as JProperty).Where(y => y.Name == "num_market_pairs").FirstOrDefault();
                JProperty ts = tokensFromJsonData.Children().Select(x => x as JProperty).Where(y => y.Name == "total_supply").FirstOrDefault();
                CurrencyInfoToReturn.TotalSupply = (ts.Value.ToString() != "") ? (long)ts : 0;
                JProperty ms = tokensFromJsonData.Children().Select(x => x as JProperty).Where(y => y.Name == "max_supply").FirstOrDefault();
                CurrencyInfoToReturn.MaxSupply = (ms.Value.ToString() != "") ? (long)ms : 0;
                string recievedDateToParse = ((string)tokensFromJsonData.Children().Select(x => x as JProperty).Where(y => y.Name == "date_added").FirstOrDefault());
                CurrencyInfoToReturn.DateAdded       = DateTime.ParseExact(recievedDateToParse, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                recievedDateToParse                  = ((string)tokensFromJsonData.Children().Select(x => x as JProperty).Where(y => y.Name == "last_updated").FirstOrDefault());
                CurrencyInfoToReturn.LastTimeUpdated = DateTime.ParseExact(recievedDateToParse, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                IList <JToken> tokensFromJsonQuote = tokensFromJsonData.Children().Select(x => x as JProperty).Where(y => y.Name == "quote").FirstOrDefault();

                CurrencyQuote quoteToReturn = new CurrencyQuote();

                foreach (JToken quoteToken in tokensFromJsonQuote)
                {
                    quoteToReturn.Currency = returnEnum((string)quoteToken.Children().Select(x => x as JProperty).FirstOrDefault().Name);

                    JToken quoteTokenValues = quoteToken.Children().First();
                    quoteToReturn.percentChange24 = (decimal)quoteTokenValues.Values().Select(x => x as JProperty).Where(y => y.Name == "percent_change_24h").FirstOrDefault();

                    CurrencyLongTermValues cLTV = new CurrencyLongTermValues();

                    string date = (string)quoteTokenValues.Values().Select(x => x as JProperty).Where(y => y.Name == "last_updated").FirstOrDefault();
                    cLTV.actualAt  = DateTime.ParseExact(date, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                    cLTV.price     = (decimal)quoteTokenValues.Values().Select(x => x as JProperty).Where(y => y.Name == "price").FirstOrDefault();
                    cLTV.volume24  = (decimal)quoteTokenValues.Values().Select(x => x as JProperty).Where(y => y.Name == "volume_24h").FirstOrDefault();
                    cLTV.marketCap = (decimal)quoteTokenValues.Values().Select(x => x as JProperty).Where(y => y.Name == "market_cap").FirstOrDefault();

                    quoteToReturn.LongeTermValues.Add(cLTV);
                    CurrencyInfoToReturn.Quotes.Add(quoteToReturn);
                }

                currencyInfoToReturn.Add(CurrencyInfoToReturn);
            }


            return(currencyInfoToReturn);
        }