Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

ExchangeRatePluginManager.cs

using Nop.Core.Domain.Customers;
using Nop.Core.Domain.Directory;
using Nop.Services.Customers;
using Nop.Services.Plugins;

namespace Nop.Services.Directory;

/// 
/// Represents an exchange rate plugin manager implementation
/// 
public partial class ExchangeRatePluginManager : PluginManager, IExchangeRatePluginManager
{
    #region Fields

    protected readonly CurrencySettings _currencySettings;

    #endregion

    #region Ctor

    public ExchangeRatePluginManager(CurrencySettings currencySettings,
        ICustomerService customerService,
        IPluginService pluginService) : base(customerService, pluginService)
    {
        _currencySettings = currencySettings;
    }

    #endregion

    #region Methods

    /// 
    /// Load primary active exchange rate provider
    /// 
    /// Filter by customer; pass null to load all plugins
    /// Filter by store; pass 0 to load all plugins
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the exchange rate provider
    /// 
    public virtual async Task LoadPrimaryPluginAsync(Customer customer = null, int storeId = 0)
    {
        return await LoadPrimaryPluginAsync(_currencySettings.ActiveExchangeRateProviderSystemName, customer, storeId);
    }

    /// 
    /// Check whether the passed exchange rate provider is active
    /// 
    /// Exchange rate provider to check
    /// Result
    public virtual bool IsPluginActive(IExchangeRateProvider exchangeRateProvider)
    {
        return IsPluginActive(exchangeRateProvider, [_currencySettings.ActiveExchangeRateProviderSystemName]);
    }

    #endregion
}