Beispiel #1
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);
        }
Beispiel #2
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);
        }
Beispiel #3
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);
        }