Пример #1
0
        private IEnumerable <CryptoAsset> FilterNotSavedAssets(IEnumerable <CryptoAsset> allAssets)
        {
            ICryptoTickerRepository             cryptoTickerRepository = new CryptoTickerRepository(this.DataContext);
            List <Data.DataModels.CryptoTicker> existingAssets         = cryptoTickerRepository.FindAll().ToList();

            return(allAssets.Where(a => !existingAssets.Any(ea => string.Compare(ea.Ticker, a.Symbol, true) == 0)));
        }
Пример #2
0
        internal void SaveCoinbaseDataToDb()
        {
            ICryptoTickerRepository       cryptoTickerRepository       = new CryptoTickerRepository(this.DataContext);
            ICurrencySymbolRepository     currencySymbolRepository     = new CurrencySymbolRepository(this.DataContext);
            ICryptoTradeHistoryRepository cryptoTradeHistoryRepository = new CryptoTradeHistoryRepository(this.DataContext);
            CoinbaseParser coinbaseParser = new CoinbaseParser(cryptoTickerRepository, currencySymbolRepository, cryptoTradeHistoryRepository);

            coinbaseParser.ParseCoinbaseReport();
        }
Пример #3
0
        /// <summary>
        /// Download all assets to SQL database
        /// </summary>
        internal async Task DownloadAssets()
        {
            CryptoWatch cryptoWatch          = new CryptoWatch(new HttpClient());
            IEnumerable <CryptoAsset> assets = await cryptoWatch.GetAssets();

            ICryptoTickerRepository cryptoTickerRepository = new CryptoTickerRepository(this.DataContext);

            assets = this.FilterNotSavedAssets(assets);

            foreach (CryptoAsset asset in assets)
            {
                this.CreateTickerEntity(asset, cryptoTickerRepository);
            }

            cryptoTickerRepository.Save();
        }