public ActionResult TopMenu() { //categories var customerRolesIds = _workContext.CurrentCustomer.CustomerRoles .Where(cr => cr.Active).Select(cr => cr.Id).ToList(); string categoryCacheKey = string.Format(ModelCacheEventConsumer.CATEGORY_MENU_MODEL_KEY, _workContext.WorkingLanguage.Id, string.Join(",", customerRolesIds), _storeContext.CurrentStore.Id); var cachedCategoriesModel = _cacheManager.Get(categoryCacheKey, () => { return PrepareCategorySimpleModels(0, null, 0, _catalogSettings.TopCategoryMenuSubcategoryLevelsToDisplay, true).ToList(); }); //top menu topics string topicCacheKey = string.Format(ModelCacheEventConsumer.TOPIC_TOP_MENU_MODEL_KEY, _workContext.WorkingLanguage.Id, _storeContext.CurrentStore.Id); var cachedTopicModel = _cacheManager.Get(topicCacheKey, () => { return _topicService.GetAllTopics(_storeContext.CurrentStore.Id) .ToList() .FindAll(t => t.IncludeInTopMenu) .ToList() .Select(t => new TopMenuModel.TopMenuTopicModel() { Id = t.Id, Name = t.GetLocalized(x => x.Title), SeName = t.GetSeName() }) .ToList(); }); var model = new TopMenuModel() { Categories = cachedCategoriesModel, Topics = cachedTopicModel, RecentlyAddedProductsEnabled = _catalogSettings.RecentlyAddedProductsEnabled, BlogEnabled = _blogSettings.Enabled, ForumEnabled = _forumSettings.ForumsEnabled }; model.ShoppingCartItems = _workContext.CurrentCustomer.ShoppingCartItems .Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart) .LimitPerStore(_storeContext.CurrentStore.Id) .ToList() .GetTotalProducts(); return PartialView(model); }
public ActionResult TopMenu() { var customerRolesIds = _workContext.CurrentCustomer.CustomerRoles .Where(cr => cr.Active).Select(cr => cr.Id).ToList(); string cacheKey = string.Format(ModelCacheEventConsumer.CATEGORY_MENU_MODEL_KEY, _workContext.WorkingLanguage.Id, string.Join(",", customerRolesIds), _storeContext.CurrentStore.Id); var cachedModel = _cacheManager.Get(cacheKey, () => { return PrepareCategorySimpleModels(0, null, 0, _catalogSettings.TopCategoryMenuSubcategoryLevelsToDisplay, true).ToList(); }); var model = new TopMenuModel() { Categories = cachedModel, RecentlyAddedProductsEnabled = _catalogSettings.RecentlyAddedProductsEnabled, BlogEnabled = _blogSettings.Enabled, ForumEnabled = _forumSettings.ForumsEnabled }; return PartialView(model); }
public ActionResult TopMenu() { //categories string categoryCacheKey = string.Format(ModelCacheEventConsumer.CATEGORY_MENU_MODEL_KEY, _workContext.WorkingLanguage.Id, string.Join(",", _workContext.CurrentCustomer.GetCustomerRoleIds()), _storeContext.CurrentStore.Id); var cachedCategoriesModel = _cacheManager.Get(categoryCacheKey, () => PrepareCategorySimpleModels(0)); //top menu topics string topicCacheKey = string.Format(ModelCacheEventConsumer.TOPIC_TOP_MENU_MODEL_KEY, _workContext.WorkingLanguage.Id, _storeContext.CurrentStore.Id); var cachedTopicModel = _cacheManager.Get(topicCacheKey, () => _topicService.GetAllTopics(_storeContext.CurrentStore.Id) .Where(t => t.IncludeInTopMenu) .Select(t => new TopMenuModel.TopMenuTopicModel { Id = t.Id, Name = t.GetLocalized(x => x.Title), SeName = t.GetSeName() }) .ToList() ); var model = new TopMenuModel { Categories = cachedCategoriesModel, Topics = cachedTopicModel, RecentlyAddedProductsEnabled = _catalogSettings.RecentlyAddedProductsEnabled, BlogEnabled = _blogSettings.Enabled, ForumEnabled = _forumSettings.ForumsEnabled }; return PartialView(model); }
public ActionResult TopMenu() { var topicModel = new TopMenuModel { Topics = new List<TopMenuModel.TopMenuTopicModel> { //new TopMenuModel.TopMenuTopicModel //{ // Id = 2, // Name = "Главная" //}, //new TopMenuModel.TopMenuTopicModel //{ // Id = 2, // Name = "Новости", // //SeName = "News" //}, new TopMenuModel.TopMenuTopicModel { Id = 3, Name = "Регламент", SeName = "Regulations" }, new TopMenuModel.TopMenuTopicModel { Id = 4, Name = "Рейтинг", SeName = "Rating" }, new TopMenuModel.TopMenuTopicModel { Id = 5, Name = "Игроки", SeName = "Players", }, //new TopMenuModel.TopMenuTopicModel //{ // Id = 6, // Name = "Head 2 Head", // SeName = "Head2Head" //}, new TopMenuModel.TopMenuTopicModel { Id = 7, Name = "Турниры", SeName = "Tournaments" }, new TopMenuModel.TopMenuTopicModel { Id = 8, Name = "Теннисные клубы", SeName = "Clubs" }, //new TopMenuModel.TopMenuTopicModel //{ // Id = 9, // Name = "Shop", // SeName = "Shop" //} } }; return View("~/Plugins/Misc.LLT/Views/TopMenu.cshtml", topicModel); }