public ActionResult CurrencySelector()
        {
            var availableCurrencies = _cacheManager.Get(string.Format(ModelCacheEventConsumer.AVAILABLE_CURRENCIES_MODEL_KEY, _workContext.WorkingLanguage.Id, _storeContext.CurrentStore.Id), () =>
            {
                var result = _currencyService
                    .GetAllCurrencies(storeId: _storeContext.CurrentStore.Id)
                    .Select(x =>
                    {
                        //currency char
                        var currencySymbol = "";
                        if (!string.IsNullOrEmpty(x.DisplayLocale))
                            currencySymbol = new RegionInfo(x.DisplayLocale).CurrencySymbol;
                        else
                            currencySymbol = x.CurrencyCode;
                        //model
                        var currencyModel = new CurrencyModel()
                        {
                            Id = x.Id,
                            Name = x.GetLocalized(y => y.Name),
                            CurrencySymbol = currencySymbol
                        };
                        return currencyModel;
                    })
                    .ToList();
                return result;
            });

            var model = new CurrencySelectorModel()
            {
                CurrentCurrencyId = _workContext.WorkingCurrency.Id,
                AvailableCurrencies = availableCurrencies
            };

            if (model.AvailableCurrencies.Count == 1)
                Content("");

            return PartialView(model);
        }
Esempio n. 2
0
 private CurrencySelectorModel PrepareCurrencySelectorModel()
 {
     var model = new CurrencySelectorModel()
     {
         CurrentCurrency = _workContext.WorkingCurrency.ToModel(),
         AvailableCurrencies = _currencyService.GetAllCurrencies().Select(x => x.ToModel()).ToList()
     };
     return model;
 }
Esempio n. 3
0
 public ActionResult CurrencySelected(int customerCurrency)
 {
     var currency = _currencyService.GetCurrencyById(customerCurrency);
     if (currency != null)
     {
         _workContext.WorkingCurrency = currency;
     }
     var model = new CurrencySelectorModel();
     model.CurrentCurrency = _workContext.WorkingCurrency.ToModel();
     model.AvailableCurrencies = _currencyService.GetAllCurrencies().Select(x => x.ToModel()).ToList();
     return PartialView("CurrencySelector", model);
 }
Esempio n. 4
0
 public ActionResult CurrencySelector()
 {
     var model = new CurrencySelectorModel();
     model.CurrentCurrency = _workContext.WorkingCurrency.ToModel();
     model.AvailableCurrencies = _currencyService.GetAllCurrencies().Select(x => x.ToModel()).ToList();
     return PartialView(model);
 }
Esempio n. 5
0
        protected CurrencySelectorModel PrepareCurrencySelectorModel()
        {
            var availableCurrencies = _cacheManager.Get(string.Format(ModelCacheEventConsumer.AVAILABLE_CURRENCIES_MODEL_KEY, _workContext.WorkingLanguage.Id), () =>
            {
                var result = _currencyService
                    .GetAllCurrencies()
                    .Select(x => new CurrencyModel()
                    {
                        Id = x.Id,
                        Name = x.GetLocalized(y => y.Name),
                    })
                    .ToList();
                return result;
            });

            var model = new CurrencySelectorModel()
            {
                CurrentCurrencyId = _workContext.WorkingCurrency.Id,
                AvailableCurrencies = availableCurrencies
            };
            return model;
        }