コード例 #1
0
        public static Language GetSelectedLanguage(HttpContextBase context, string defaultCultureCode = null, Market market = null)
        {
            market = market ?? GetCurrentMarket(context);
            var cultureCode = GetSelectedCultureCode(context, defaultCultureCode);
            var language    = GlobalUtilities.GetLanguage(cultureCode, market);

            return(language);
        }
コード例 #2
0
        public static Language GetLanguageByCustomerID(int customerID)
        {
            // Get the user's language preference based on their saved preference
            var customer = ExigoDAL.GetCustomer(customerID);
            var market   = GlobalUtilities.GetMarket(customer.MainAddress.Country);
            var language = GlobalUtilities.GetLanguage(customer.LanguageID, market);

            // Return the language
            return(language);
        }
コード例 #3
0
        public static string GetSelectedCultureCode(HttpContextBase context, string defaultCultureCode = null)
        {
            // get the cookie (generates using default value if not available)
            var value = GlobalUtilities.GetCookie(
                context,
                cookieName: GlobalSettings.Globalization.LanguageCookieName,
                defaultValue: defaultCultureCode,
                defaultExpiration: DateTime.Now.AddYears(1),
                httpOnly: false // allow access via JavaScript
                );

            return(value);
        }
コード例 #4
0
        /// <summary>
        /// Get the selected country code
        /// </summary>
        /// <remarks>Defaults to country of the default market</remarks>
        /// <returns></returns>
        public static string GetSelectedCountryCode(HttpContextBase context, string countryCode = null)
        {
            // get market that matches country code (or default)
            var defaultMarket = GlobalUtilities.GetMarket(countryCode);
            // get the cookie (generates using default value if not available)
            var value = GlobalUtilities.GetCookie(
                context,
                cookieName: GlobalSettings.Globalization.CountryCookieName,
                defaultValue: defaultMarket.MainCountry,
                defaultExpiration: DateTime.Now.AddYears(1),
                httpOnly: false // allow access via JavaScript
                );

            // return the value
            return(value);
        }
コード例 #5
0
        public static int GetSelectedExigoLanguageID()
        {
            //If the cookie LanguagePreference exists, we set the culture code appropriately
            var languageKey = GlobalUtilities.GetSelectedLanguage();

            switch (languageKey)
            {
            // not being used
            case "fr-CA": return(Languages.French);

            case "es-US": return(Languages.Spanish);

            case "en-US":
            default: return(Languages.English);
            }
        }
コード例 #6
0
        /// <summary>
        /// Sets the selected country code
        /// </summary>
        /// <returns></returns>
        public static string SetSelectedCountryCode(HttpContextBase context, string countryCode)
        {
            // get the market for the selected country
            var market = GlobalUtilities.GetMarket(countryCode);
            // get the current cookie value (generates if it doesn't exist)
            var value = GetSelectedCountryCode(context, market.MainCountry);

            // if existing value is different, set with new value
            if (!value.Equals_IgnoreCase(market.MainCountry))
            {
                value = market.MainCountry;
                GlobalUtilities.SetCookie(
                    context,
                    name: GlobalSettings.Globalization.CountryCookieName,
                    value: value);
            }
            // return the value
            return(value);
        }
コード例 #7
0
        /// <summary>
        /// Gets the configuration, based on the country cookie
        /// </summary>
        public static Market GetCurrentMarket(HttpContextBase context)
        {
            var countryCode = GlobalUtilities.GetSelectedCountryCode(context);

            return(GetMarket(countryCode));
        }
コード例 #8
0
        /// <summary>
        /// Gets the configuration, based on the country cookie
        /// </summary>
        public static Market GetCurrentMarket()
        {
            var countryCode = GlobalUtilities.GetSelectedCountryCode();

            return(GlobalSettings.Markets.AvailableMarkets.FirstOrDefault(c => c.Countries.Contains(countryCode)));
        }