Esempio n. 1
0
        public ActionResult List(GridCommand command, MenuRecordListModel model)
        {
            var gridModel = new GridModel <MenuRecordModel>();

            if (Services.Permissions.Authorize(StandardPermissionProvider.ManageMenus))
            {
                var menus = _menuStorage.GetAllMenus(model.SystemName, model.StoreId, true, command.Page - 1, command.PageSize);

                gridModel.Data = menus.Select(x =>
                {
                    var itemModel = new MenuRecordModel();
                    MiniMapper.Map(x, itemModel);

                    return(itemModel);
                });

                gridModel.Total = menus.TotalCount;
            }
            else
            {
                gridModel.Data = Enumerable.Empty <MenuRecordModel>();
                NotifyAccessDenied();
            }

            return(new JsonResult
            {
                MaxJsonLength = int.MaxValue,
                Data = gridModel
            });
        }
Esempio n. 2
0
        public ActionResult Edit(int id)
        {
            var topic = _topicService.GetTopicById(id);

            if (topic == null)
            {
                return(RedirectToAction("List"));
            }

            var model = topic.ToModel();

            model.Url        = GetTopicUrl(topic);
            model.WidgetZone = topic.WidgetZone.SplitSafe(",");

            PrepareStoresMappingModel(model, topic, false);
            PrepareAclModel(model, topic, false);

            AddLocales(_languageService, model.Locales, (locale, languageId) =>
            {
                locale.ShortTitle      = topic.GetLocalized(x => x.ShortTitle, languageId, false, false);
                locale.Title           = topic.GetLocalized(x => x.Title, languageId, false, false);
                locale.Intro           = topic.GetLocalized(x => x.Intro, languageId, false, false);
                locale.Body            = topic.GetLocalized(x => x.Body, languageId, false, false);
                locale.MetaKeywords    = topic.GetLocalized(x => x.MetaKeywords, languageId, false, false);
                locale.MetaDescription = topic.GetLocalized(x => x.MetaDescription, languageId, false, false);
                locale.MetaTitle       = topic.GetLocalized(x => x.MetaTitle, languageId, false, false);
                locale.SeName          = topic.GetSeName(languageId, false, false);
            });

            // Get menu links.
            IPagedList <MenuRecord> menus = null;
            var pageIndex = 0;

            do
            {
                menus = _menuStorage.GetAllMenus(null, 0, true, pageIndex++, 500);

                foreach (var menu in menus)
                {
                    foreach (var item in menu.Items.Where(x => x.ProviderName != null && x.ProviderName == "entity"))
                    {
                        var link = _linkResolver.Resolve(item.Model);
                        if (link.Type == LinkType.Topic && link.Id == topic.Id)
                        {
                            var url = Url.Action("EditItem", "Menu", new { id = item.Id, area = "Admin" });

                            var label = string.Concat(
                                menu.Title.NullEmpty() ?? menu.SystemName.NullEmpty() ?? "".NaIfEmpty(),
                                " » ",
                                item.Title.NullEmpty() ?? link.Label.NullEmpty() ?? "".NaIfEmpty());

                            model.MenuLinks[url] = label;
                        }
                    }
                }
            }while (menus.HasNextPage);

            return(View(model));
        }
        public ActionResult List(GridCommand command, MenuRecordListModel model)
        {
            var gridModel = new GridModel <MenuRecordModel>();

            var menus = _menuStorage.GetAllMenus(model.SystemName, model.StoreId, true, command.Page - 1, command.PageSize);

            gridModel.Data = menus.Select(x =>
            {
                var itemModel = new MenuRecordModel();
                MiniMapper.Map(x, itemModel);

                return(itemModel);
            });

            gridModel.Total = menus.TotalCount;

            return(new JsonResult
            {
                MaxJsonLength = int.MaxValue,
                Data = gridModel
            });
        }