private async Task UpdateCurrencyList()
        {
            using (var scope = _scopeFactory.CreateScope())
            {
                var dbContext = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>();
                var coinApi   = new CoinApi(_configuration);

                var allCurrencies = dbContext.Currencies.ToList();

                if (allCurrencies.Count == 0)
                {
                    allCurrencies = await coinApi.GetAllAssets();

                    dbContext.Currencies.AddRange(allCurrencies);
                    dbContext.SaveChanges();
                }
                else
                {
                    var lastDate = allCurrencies.First().Date;
                    if (DateTime.Now - lastDate < TimeSpan.FromDays(3))
                    {
                        allCurrencies = await coinApi.GetAllAssets();

                        dbContext.Currencies.UpdateRange(allCurrencies);
                        dbContext.SaveChanges();
                    }
                }
            }
        }
        private async Task <List <Currency> > GetCurrencies(bool onlyCrypto)
        {
            var allCurrencies = dbContext.Currencies.ToList();

            if (allCurrencies.Count == 0)
            {
                allCurrencies = await coinApi.GetAllAssets();

                dbContext.Currencies.AddRange(allCurrencies);
                dbContext.SaveChanges();
            }

            var currencies = onlyCrypto ? allCurrencies.Where(c => c.IsCrypto).ToList() : allCurrencies.ToList();

            return(currencies);
        }