Exemplo n.º 1
0
        public static Language GetLanguageByCustomerID(int customerID)
        {
            var defaultCultureCode = GlobalSettings.Markets.AvailableMarkets.FirstOrDefault(c => c.IsDefault).CultureCode;
            var defaultLanguage    = Exigo.GetLanguages().FirstOrDefault(c => c.CultureCode == defaultCultureCode).LanguageID;

            var languageID = defaultLanguage;

            // Get the user's language preference based on their saved preference
            if (HttpContext.Current.Request.IsAuthenticated)
            {
                using (var sqlContext = Exigo.Sql())
                {
                    languageID = sqlContext.Query <int>(@"select top 1 LanguageID from Customers where CustomerID = @customerID", new { customerID = customerID }).FirstOrDefault();
                }
            }

            var language = Exigo.GetLanguageByID(languageID);

            // If we couldn't find the user's preferred language, return the first one we find.
            if (language == null)
            {
                language = Exigo.GetLanguages().FirstOrDefault();
            }

            // Return the language
            return(language);
        }
Exemplo n.º 2
0
        public static void SetCustomerPreferredLanguage(int customerID, int languageID)
        {
            Exigo.WebService().UpdateCustomer(new UpdateCustomerRequest
            {
                CustomerID = customerID,
                LanguageID = languageID
            });

            var language = Exigo.GetLanguageByID(languageID);

            if (language != null)
            {
                GlobalUtilities.SetCurrentUICulture(language.CultureCode);
            }
        }