Ejemplo n.º 1
0
        private async Task UpdateIconsAsync(IEnumerable <AssetResult> assetResults)
        {
            var assets = AssetBusiness.ListAll();

            foreach (var assetData in assetResults)
            {
                var asset = assets.FirstOrDefault(c => c.CoinGeckoId == assetData.Id);
                if (asset != null)
                {
                    await UploadAssetIconAsync(asset.Id, assetData.ImageUrl);
                }
            }
        }
Ejemplo n.º 2
0
        private async Task CreateNotIncludedAssetsAsync(IEnumerable <AssetResult> assetResults)
        {
            var assets = AssetBusiness.ListAll();

            foreach (var asset in assetResults)
            {
                if (!asset.Price.HasValue)
                {
                    continue;
                }

                if (assets.Any(c => c.CoinGeckoId == asset.Id))
                {
                    continue;
                }

                var newAsset = new DomainObjects.Asset.Asset()
                {
                    Code                = asset.Symbol.ToUpper(),
                    Name                = asset.Name,
                    Type                = AssetType.Crypto.Value,
                    MarketCap           = asset.MarketCap,
                    CirculatingSupply   = asset.CirculatingSupply,
                    ShortSellingEnabled = true,
                    CoinGeckoId         = asset.Id
                };

                using (var transaction = TransactionalDapperCommand)
                {
                    transaction.Insert(newAsset);
                    transaction.Insert(new AssetCurrentValue()
                    {
                        CurrentValue = asset.Price.Value, Id = newAsset.Id, UpdateDate = Data.GetDateTimeNow()
                    });
                    transaction.Commit();
                }
                await UploadAssetIconAsync(newAsset.Id, asset.ImageUrl);
            }
        }