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 }); }
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); }