public async Task UpdateAsync(Instrument instrument, string userId) { Instrument currentInstrument = await GetByAssetPairIdAsync(instrument.AssetPairId); InstrumentMode currentInstrumentMode = currentInstrument.Mode; currentInstrument.Update(instrument); currentInstrument.Approve(); await _instrumentRepository.UpdateAsync(currentInstrument); _cache.Set(currentInstrument); if (instrument.Mode == InstrumentMode.Disabled && currentInstrumentMode != InstrumentMode.Disabled) { try { await _lykkeExchangeService.CancelAsync(instrument.AssetPairId); } catch (Exception exception) { _log.WarningWithDetails("An error occurred while cancelling limit orders", exception, new { currentInstrument, userId }); } await _orderBookService.RemoveAsync(instrument.AssetPairId); } _log.InfoWithDetails("Instrument was updated", new { currentInstrument, userId }); }
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 }); }