Example #1
0
        public async Task <IAsset> DeleteAsset(string assetId)
        {
            var asset = await _assetRepository.DeleteAsync(assetId);

            InitCache();
            return(asset);
        }
        public async Task <IActionResult> DeleteAsync(int id)
        {
            try {
                await _assetRepository.DeleteAsync(id);
            } catch (InvalidOperationException e) {
                _logger.LogInformation(e, $"Found no asset entry with id: {id}.");
                return(NotFound(e.Message));
            }

            return(NoContent());
        }
Example #3
0
        public async Task <IActionResult> Delete(Guid id)
        {
            var entity = await _repository.GetAsync(id);

            if (entity == null)
            {
                return(NotFound());
            }
            await _repository.DeleteAsync(entity);

            return(Ok());
        }
Example #4
0
        public async Task <Result> DeleteAsync(int id)
        {
            try
            {
                await _assetRepository.DeleteAsync(id);

                return(new Result());
            }
            catch (Exception ex)
            {
                return(new Result <Asset>(null, "Erro ao deletar ativo"));
            }
        }
        public async Task DeleteAssetAsync(string name, string exchange, string userId)
        {
            Asset existingAsset = await GetAssetAsync(name, exchange);

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

            IReadOnlyCollection <AssetPair> assetPairsSettings = await GetAssetPairsAsync();

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

            await _assetRepository.DeleteAsync(name, exchange);

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

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