public async Task AddCrossInstrumentAsync(string assetPairId, CrossInstrument crossInstrument) { IReadOnlyCollection <Instrument> instruments = await GetAllAsync(); if (instruments.Any(o => o.AssetPairId == crossInstrument.AssetPairId || o.CrossInstruments?.Any(p => p.AssetPairId == crossInstrument.AssetPairId) == true)) { throw new InvalidOperationException("The instrument already used"); } Instrument instrument = await GetByAssetPairIdAsync(assetPairId); instrument.AddCrossInstrument(crossInstrument); await _crossInstrumentRepository.AddAsync(assetPairId, crossInstrument); _cache.Set(instrument); _log.InfoWithDetails("Cross instrument was added to the instrument", instrument); }