public async Task AddAsync(Instrument instrument, string userId)
        {
            instrument.Approve();

            await _instrumentRepository.InsertAsync(instrument);

            _cache.Set(instrument);

            _log.InfoWithDetails("Instrument was added", new { instrument, userId });
        }
Ejemplo n.º 2
0
        public async Task AddAsync(Instrument instrument)
        {
            IReadOnlyCollection <Instrument> instruments = await GetAllAsync();

            if (instruments.Any(o => o.AssetPairId == instrument.AssetPairId ||
                                o.CrossInstruments?.Any(p => p.AssetPairId == instrument.AssetPairId) ==
                                true))
            {
                throw new InvalidOperationException("The instrument already used");
            }

            await _instrumentRepository.InsertAsync(instrument);

            _cache.Set(instrument);

            _log.InfoWithDetails("Instrument was added", instrument);
        }