Ejemplo n.º 1
0
        public virtual StoreSelectorModel PrepareStoreSelector()
        {
            if (!_commonSettings.AllowToSelectStore)
            {
                return(null);
            }

            var availableStores = _cacheManager.Get(ModelCacheEventConsumer.AVAILABLE_STORES_MODEL_KEY, () =>
            {
                var result = _storeService.GetAllStores()
                             .Select(x => new StoreModel
                {
                    Id   = x.Id,
                    Name = x.Name,
                })
                             .ToList();
                return(result);
            });

            var model = new StoreSelectorModel
            {
                CurrentStoreId  = _storeContext.CurrentStore.Id,
                AvailableStores = availableStores,
            };

            return(model);
        }
Ejemplo n.º 2
0
        public ActionResult StoreSelector()
        {
            var availableStores = _cacheManager.Get(string.Format(ModelCacheEventConsumer.STORES_MODEL_KEY, _storeContext.CurrentStore.Id, _workContext.WorkingLanguage.Id), () =>
            {
                var result = _storeService
                             .GetAllStores()
                             .Select(x => new StoreModel
                {
                    Id      = x.Id,
                    Name    = x.GetLocalized(q => q.Name),
                    Url     = x.Url,
                    Country = x.CompanyName
                })
                             .ToList();
                return(result);
            });

            var model = new StoreSelectorModel
            {
                CurrentStoreId  = _storeContext.CurrentStore.Id,
                AvailableStores = availableStores,
            };

            if (model.AvailableStores.Count == 1)
            {
                Content("");
            }

            return(PartialView(model));
        }
Ejemplo n.º 3
0
        public async Task <StoreSelectorModel> PrepareStoreSelector()
        {
            if (!_commonSettings.AllowToSelectStore)
            {
                return(null);
            }

            var availableStores = (await _storeService.GetAllStores())
                                  .Select(x => new StoreModel {
                Id   = x.Id,
                Name = x.Shortcut,
            }).ToList();

            var model = new StoreSelectorModel {
                CurrentStoreId  = _storeContext.CurrentStore.Id,
                AvailableStores = availableStores,
            };

            return(model);
        }