Exemple #1
0
        public async Task DeleteAsync(string assetId)
        {
            if (assetId == AssetConsts.UsdAssetId)
            {
                throw new InvalidOperationException("Can not delete non-editable asset.");
            }

            Domain.AssetSettings assetSettings = await GetByIdAsync(assetId);

            if (assetSettings == null)
            {
                throw new EntityNotFoundException();
            }

            await _assetSettingsRepository.DeleteAsync(assetId);

            _cache.Remove(assetId);

            _log.InfoWithDetails("Asset settings were deleted", assetSettings);
        }
Exemple #2
0
        public async Task DeleteAssetAsync(string asset, string exchange, string userId)
        {
            AssetSettings existingAssetSettings = await GetAssetAsync(asset, exchange);

            if (existingAssetSettings == null)
            {
                throw new EntityNotFoundException();
            }

            IReadOnlyCollection <AssetPairSettings> assetPairsSettings = await GetAssetPairsAsync();

            if (assetPairsSettings.Any(o => o.Exchange == exchange && (o.BaseAsset == asset || o.QuoteAsset == asset)))
            {
                throw new InvalidOperationException("Asset is used by asset pair.");
            }

            await _assetSettingsRepository.DeleteAsync(asset, exchange);

            _assetsCache.Remove(GetKey(asset, exchange));

            _log.InfoWithDetails("Asset settings deleted", new { existingAssetSettings, userId });
        }