public async Task CmcSaveCryptosData(List <Crypto> cryptos)
 {
     if (!_cryptoRepository.GetAll().Any())
     {
         await _cryptoRepository.AddRange(cryptos);
     }
     else
     {
         foreach (var crypto in cryptos)
         {
             var cryptoToUpdate = _cryptoRepository.GetCryptoByIdCrypto(crypto.IdCrypto);
             if (cryptoToUpdate != null)
             {
                 cryptoToUpdate.Price     = crypto.Price;
                 cryptoToUpdate.Change24h = crypto.Change24h;
                 cryptoToUpdate.Change7d  = crypto.Change7d;
                 await _cryptoRepository.UpdateAsync(cryptoToUpdate);
             }
         }
     }
 }
Beispiel #2
0
 public async Task <Crypto> UpdateAsync(Crypto crypto)
 {
     return(await _cryptoRepository.UpdateAsync(crypto));
 }