private Task <EnabledMarginTradingTypes> IsMarginTradingEnabledInternal(string clientId) { async Task <EnabledMarginTradingTypes> MarginEnabled() { var marginEnabledSettings = await _clientAccountService.GetMarginEnabledAsync(clientId); return(new EnabledMarginTradingTypes { Demo = marginEnabledSettings.Enabled, Live = marginEnabledSettings.EnabledLive }); } return(_cacheProvider.GetAsync(GetClientTradingEnabledCacheKey(clientId), async() => new CachableResult <EnabledMarginTradingTypes>(await MarginEnabled(), ClientTradingEnabledCachingParameters))); }
public async Task SetMarginTradingEnabled(string clientId, bool enabled) { var settings = await _clientAccountService.GetMarginEnabledAsync(clientId); settings.EnabledLive = enabled; settings.Enabled = enabled; await _clientAccountService.SetMarginEnabledAsync(clientId, settings.Enabled, settings.EnabledLive, settings.TermsOfUseAgreed); var marginEnabledChangedMessage = new MarginTradingEnabledChangedMessage { ClientId = clientId, EnabledDemo = settings.Enabled, EnabledLive = settings.EnabledLive }; _marginTradingSettingsCacheService.OnMarginTradingEnabledChanged(marginEnabledChangedMessage); await _eventsPublisher.ProduceAsync(marginEnabledChangedMessage); }