Atomia.Web.Plugin.PublicOrder.Helpers.CountriesHelper.GetDefaultCurrencyCodeFromConfig C# (CSharp) Method

GetDefaultCurrencyCodeFromConfig() public static method

Gets the default currency code from config.
If no code is set to default, currency code is determined by country code.
public static GetDefaultCurrencyCodeFromConfig ( string countryCode ) : string
countryCode string The country code.
return string
        public static string GetDefaultCurrencyCodeFromConfig(string countryCode)
        {
            string currencyCode = string.Empty;
            PublicOrderConfigurationSection opcs = LocalConfigurationHelper.GetLocalConfigurationSection();
            CountryItem defaultCountryItem = opcs.CountriesList.Cast<CountryItem>().ToList().Find(x => x.Default);
            if (defaultCountryItem == null && !string.IsNullOrEmpty(countryCode))
            {
                defaultCountryItem = opcs.CountriesList.Cast<CountryItem>().ToList().Find(x => x.Code.EndsWith(countryCode));
            }

            if (defaultCountryItem != null)
            {
                currencyCode = defaultCountryItem.Currency;
            }

            return currencyCode;
        }