public ExchangeExtPriceSettings Add(string assetPairId, string exchangeName, string reason) { var newExchange = GetDefaultExchange(); Update(assetPairId, old => AssetPairExtPriceSettings.Change(old, old.Exchanges.Add(exchangeName, newExchange)), reason); return(newExchange); }
public void Delete(string assetPairId, string exchangeName, string reason) { if (TryGetExchange(assetPairId, exchangeName) == null) { throw new Exception($"Exchange {exchangeName} not exist for asset pair {assetPairId}"); } Update(assetPairId, old => AssetPairExtPriceSettings.Change(old, old.Exchanges.Remove(exchangeName)), reason); }
private void UpdateExchanges(string assetPairId, IEnumerable <string> exchangeNames, Func <ExchangeExtPriceSettings, ExchangeExtPriceSettings> changeFunc, string reason) { var exchangesHashSet = exchangeNames.ToImmutableHashSet(); Update(assetPairId, old => { var newExchanges = old.Exchanges .SetItems(old.Exchanges.Where(o => exchangesHashSet.Contains(o.Key)) .Select(s => KeyValuePair.Create(s.Key, changeFunc(s.Value)))); return(AssetPairExtPriceSettings.Change(old, newExchanges)); }, reason); }
public void UpdateWithoutExchanges(string assetPairId, AssetPairExtPriceSettings setting, string reason) { Update(assetPairId, old => AssetPairExtPriceSettings.Change(setting, old.Exchanges), reason); }