/// <summary> /// Prepare exchange rate provider model /// </summary> /// <param name="model">Currency exchange rate provider model</param> /// <param name="prepareExchangeRates">Whether to prepare exchange rate models</param> protected virtual void PrepareExchangeRateProviderModel(CurrencyExchangeRateProviderModel model, bool prepareExchangeRates) { if (model == null) { throw new ArgumentNullException(nameof(model)); } model.AutoUpdateEnabled = _currencySettings.AutoUpdateEnabled; //prepare available exchange rate providers var availableExchangeRateProviders = _exchangeRatePluginManager.LoadAllPlugins(); model.ExchangeRateProviders = availableExchangeRateProviders.Select(provider => new SelectListItem { Text = provider.PluginDescriptor.FriendlyName, Value = provider.PluginDescriptor.SystemName, Selected = _exchangeRatePluginManager.IsPluginActive(provider) }).ToList(); //prepare exchange rates if (prepareExchangeRates) { PrepareExchangeRateModels(model.ExchangeRates); } }
/// <summary> /// Prepare exchange rate provider model /// </summary> /// <param name="model">Currency exchange rate provider model</param> /// <param name="prepareExchangeRates">Whether to prepare exchange rate models</param> protected virtual void PrepareExchangeRateProviderModel(CurrencyExchangeRateProviderModel model, bool prepareExchangeRates) { if (model == null) { throw new ArgumentNullException(nameof(model)); } model.AutoUpdateEnabled = _currencySettings.AutoUpdateEnabled; //prepare available exchange rate providers var availableExchangeRateProviders = _currencyService.LoadAllExchangeRateProviders(_workContext.CurrentCustomer); model.ExchangeRateProviders = availableExchangeRateProviders.Select(provider => new SelectListItem { Text = provider.PluginDescriptor.FriendlyName, Value = provider.PluginDescriptor.SystemName, Selected = provider.PluginDescriptor.SystemName .Equals(_currencySettings.ActiveExchangeRateProviderSystemName, StringComparison.InvariantCultureIgnoreCase) }).ToList(); //prepare exchange rates if (prepareExchangeRates) { PrepareExchangeRateModels(model.ExchangeRates); } }