Ejemplo n.º 1
0
        public ActionResult TopMenu(int currentCategoryId, int currentProductId)
        {
            var activeCategory = _categoryService.GetCategoryById(currentCategoryId);

            if (activeCategory == null && currentProductId > 0)
            {
                var productCategories = _categoryService.GetProductCategoriesByProductId(currentProductId);
                if (productCategories.Count > 0)
                {
                    activeCategory = productCategories[0].Category;
                }
            }
            int activeCategoryId = activeCategory != null ? activeCategory.Id : 0;
            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,
                CurrentCategoryId = activeCategoryId
            };

            return(PartialView(model));
        }
Ejemplo n.º 2
0
        public IActionResult TopMenu()
        {
            var model = new TopMenuModel();

            model.UserCount = context.Users.Count();
            model.RoleCount = context.Roles.Count();
            return(View(model));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Prepare top menu model
        /// </summary>
        /// <returns>Top menu model</returns>
        public virtual TopMenuModel PrepareTopMenuModel()
        {
            var model = new TopMenuModel
            {
            };

            return(model);
        }
Ejemplo n.º 4
0
        //Todo: Consider async components. Then, after considering, implement it.
        public IViewComponentResult Invoke()
        {
            var model = new TopMenuModel {
                Number = 3
            };                                           //TODO: TopMenu should contain user data for the "Logged in" widget. Fetch from some service.

            return(View(model));
        }
Ejemplo n.º 5
0
        public virtual TopMenuModel PrepareTopMenuModel()
        {
            var model = new TopMenuModel
            {
                verticals = VerticalModels()
            };

            return(model);
        }
Ejemplo n.º 6
0
        public PartialViewResult TopMenu()
        {
            // Top menu for the current language starts at the nearest language root
            ContentItem branchRoot    = Find.ClosestLanguageRoot;
            var         selected      = Find.AncestorAtLevel(2, Find.EnumerateParents(CurrentPage, branchRoot, true), CurrentPage);
            var         topLevelPages = branchRoot.GetChildren(new NavigationFilter());
            var         model         = new TopMenuModel(GetTranslations(), selected ?? branchRoot, topLevelPages);

            return(PartialView(model));
        }
Ejemplo n.º 7
0
        public PartialViewResult TopMenu()
        {
            // Top menu for the current language starts at the nearest language root
            ContentItem branchRoot = Find.ClosestLanguageRoot;
            var         selected   = Find.AncestorAtLevel(2, Find.EnumerateParents(CurrentPage, branchRoot, true), CurrentPage);
            var         pages      = branchRoot.Children.WhereNavigatable();

            pages.Insert(0, branchRoot);
            var topLevelPages = pages.TryAppendCreatorNode(Engine, branchRoot);
            var model         = new TopMenuModel(GetTranslations(), selected ?? branchRoot, topLevelPages);

            return(PartialView(model));
        }
Ejemplo n.º 8
0
        public IViewComponentResult Invoke()
        {
            var model         = new TopMenuModel();
            var result        = new List <CategorySimpleModel>();
            var allCategories = _categoryService.GetAllCategories();

            foreach (var category in allCategories)
            {
                var categoryModel = new CategorySimpleModel
                {
                    Id               = category.Id,
                    Name             = category.Name,
                    SeName           = FriendlyUrlHelper.GetFriendlyTitle(_urlRecordService.GetSeName(category), true),
                    IncludeInTopMenu = category.IncludeInTopMenu,
                    ParentCategoryId = category.ParentCategoryId
                };
                result.Add(categoryModel);
            }
            model.Categories = result;
            return(View(model));
        }
Ejemplo n.º 9
0
        public virtual TopMenuModel PrepareTopMenuModel()
        {
            //categories
            var cachedCategoriesModel = PrepareCategorySimpleModels();

            //top menu topics
            string topicCacheKey = string.Format(ModelCacheEventConsumer.TOPIC_TOP_MENU_MODEL_KEY,
                                                 _workContext.WorkingLanguage.Id,
                                                 _storeContext.CurrentStore.Id,
                                                 string.Join(",", _workContext.CurrentCustomer.GetCustomerRoleIds()));
            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,
                NewProductsEnabled           = _catalogSettings.NewProductsEnabled,
                BlogEnabled                  = _blogSettings.Enabled,
                ForumEnabled                 = _forumSettings.ForumsEnabled,
                DisplayHomePageMenuItem      = _displayDefaultMenuItemSettings.DisplayHomePageMenuItem,
                DisplayNewProductsMenuItem   = _displayDefaultMenuItemSettings.DisplayNewProductsMenuItem,
                DisplayProductSearchMenuItem = _displayDefaultMenuItemSettings.DisplayProductSearchMenuItem,
                DisplayCustomerInfoMenuItem  = _displayDefaultMenuItemSettings.DisplayCustomerInfoMenuItem,
                DisplayBlogMenuItem          = _displayDefaultMenuItemSettings.DisplayBlogMenuItem,
                DisplayForumsMenuItem        = _displayDefaultMenuItemSettings.DisplayForumsMenuItem,
                DisplayContactUsMenuItem     = _displayDefaultMenuItemSettings.DisplayContactUsMenuItem
            };

            return(model);
        }
Ejemplo n.º 10
0
        public Task <IViewComponentResult> InvokeAsync()
        {
            var model = new TopMenuModel();

            var curent = (MenuItem)ViewContext.RouteData.Values["menu"];

            if (curent != null)
            {
                var item = curent;
                while (item != null)
                {
                    model.Crumbs.Add(new MenuItemModel
                    {
                        Title    = item.Title,
                        Path     = item.Path,
                        Active   = true,
                        Selected = curent == item
                    });
                    item = item.Parent;
                }

                model.Crumbs.Reverse();
            }

            if (!string.IsNullOrEmpty(_projectConfig.EditUrl))
            {
                var page = _pageRegistry.GetPage(HttpContext.Request.Path);
                if (page != null)
                {
                    var filePathHint = page.State as IFilePathHint;
                    if (filePathHint != null)
                    {
                        model.EditUrl = _projectConfig.EditUrl.Replace("{path}", filePathHint.FilePath);
                    }
                }
            }

            return(Task.FromResult <IViewComponentResult>(View(model)));
        }
Ejemplo n.º 11
0
        public ActionResult TopMenu()
        {
            // категории
            var categoriesModel = PrepareCategorySimpleModels(0);

            // top menu topics
            var topicModel = _topicService.GetAllTopics()
                             .Where(t => t.IncludedInTopMenu)
                             .Select(t => new TopMenuModel.TopMenuTopicModel
            {
                Id     = t.Id,
                Name   = t.Title,
                SeName = "SeName"
            })
                             .ToList();

            var model = new TopMenuModel
            {
                Categories = categoriesModel,
                Topics     = topicModel
            };

            return(PartialView(model));
        }
Ejemplo n.º 12
0
        public ActionResult TopMenu(int?customerEventId)
        {
            //Get Catalog controller
            var tmpCatalogController = DependencyResolver.Current.GetService(typeof(CatalogController)) as CatalogController;
            PartialViewResult result = (PartialViewResult)tmpCatalogController.TopMenu();

            //Current catalog topmenu model
            TopMenuModel        tmpModel        = (TopMenuModel)result.ViewData.Model;
            CameleoTopMenuModel tmpCameleoModel = new CameleoTopMenuModel();

            tmpCameleoModel.BlogEnabled  = tmpModel.BlogEnabled;
            tmpCameleoModel.ForumEnabled = tmpModel.ForumEnabled;
            tmpCameleoModel.Categories   = tmpModel.Categories;
            tmpCameleoModel.RecentlyAddedProductsEnabled = tmpModel.RecentlyAddedProductsEnabled;

            //Enable MyGroup Menu for staff ?
            //In customer event details page?
            if (customerEventId == null)
            {
                //No don't show menu
                tmpCameleoModel.MyGroupEnabled = false;
            }
            else
            {
                //Else, get customer event
                var tmpCustomerEvent = _customerEventService.GetCustomerEventById(customerEventId);
                //Found?
                if (tmpCustomerEvent == null)
                {
                    //No don't show menu
                    tmpCameleoModel.MyGroupEnabled = false;
                }
                else
                {
                    // Get event user
                    var tmpEventUser = _eventUserService.GetEventUserById(tmpCustomerEvent.EventUserId);

                    //Found?
                    if (tmpEventUser == null)
                    {
                        //No don't show menu
                        tmpCameleoModel.MyGroupEnabled = false;
                    }
                    else
                    {
                        //Else, check if staff
                        if (tmpEventUser.isStaff)
                        {
                            //Yes, show menu
                            tmpCameleoModel.MyGroupEnabled  = true;
                            tmpCameleoModel.CustomerEventId = customerEventId;
                        }
                        else
                        {
                            //Else don't show menu
                            tmpCameleoModel.MyGroupEnabled = false;
                        }
                    }
                }
            }

            //Return view
            return(PartialView(tmpCameleoModel));
        }
Ejemplo n.º 13
0
 public ActionResult FindUser(TopMenuModel model)
 {
     return(Index());
 }