Example #1
0
        public void SetCurrentMarket(MarketId marketId)
        {
            var market = GetMarket(marketId);

            SiteContext.Current.Currency = market.DefaultCurrency;
            _cookieService.Set(MarketCookie, marketId.Value);
        }
Example #2
0
        public void UpdateLanguage(string languageId)
        {
            var chosenLanguage = languageId;
            var cookieLanguage = _cookieService.Get(LanguageCookie);

            if (string.IsNullOrEmpty(chosenLanguage))
            {
                if (cookieLanguage != null)
                {
                    chosenLanguage = cookieLanguage;
                }
                else
                {
                    var currentMarket = _currentMarket.GetCurrentMarket();
                    if (currentMarket?.DefaultLanguage != null)
                    {
                        chosenLanguage = currentMarket.DefaultLanguage.Name;
                    }
                }
            }

            _defaultUpdateCurrentLanguage.UpdateLanguage(chosenLanguage);

            if (cookieLanguage == null || cookieLanguage != chosenLanguage)
            {
                _cookieService.Set(LanguageCookie, chosenLanguage);
            }
        }
Example #3
0
        public bool SetCurrentCurrency(string currencyCode)
        {
            Currency currency;

            if (!TryGetCurrency(currencyCode, out currency))
            {
                return(false);
            }

            _cookieService.Set(CurrencyCookie, currencyCode);

            return(true);
        }
        public virtual bool SetCurrentLanguage(string language)
        {
            CultureInfo cultureInfo;

            if (!TryGetLanguage(language, out cultureInfo))
            {
                return(false);
            }

            _defaultUpdateCurrentLanguage.UpdateLanguage(language);
            _cookieService.Set(LanguageCookie, language);
            return(true);
        }