public override void Setup(MenuItem menuItem)
        {
            menuItem.Name           = "Dropdown";
            menuItem.MenuTemplateId = null; // because menuitem is dropdown
            menuItem.ParentId       = null; // null is always

            _dbContext.MenuItems.Add(menuItem);
            _dbContext.SaveChanges();

            //Set translation for menu item
            SetTranslations(menuItem.Id);

            foreach (var securityGroupId in MenuItemModel.SecurityGroupsIds)
            {
                var menuItemSecurityGroup = new MenuItemSecurityGroup()
                {
                    SecurityGroupId = securityGroupId,
                    MenuItemId      = menuItem.Id,
                };

                _dbContext.MenuItemSecurityGroups.Add(menuItemSecurityGroup);
                _dbContext.SaveChanges();
            }

            for (int i = 0; i < MenuItemModel.Children.Count; i++)
            {
                var menuItemBuilder = new MenuItemBuilder(_dbContext, MenuItemModel.Children[i], i, menuItem.Id);

                menuItemBuilder.Build();
            }
        }
Пример #2
0
        public override void Setup(MenuItem menuItem)
        {
            menuItem.Name           = MenuItemModel.Name;
            menuItem.MenuTemplateId = null;
            menuItem.ParentId       = _parentId;

            _dbContext.MenuItems.Add(menuItem);
            _dbContext.SaveChanges();

            //Set translation for menu item
            SetTranslations(menuItem.Id);

            foreach (var securityGroupId in MenuItemModel.SecurityGroupsIds)
            {
                var menuItemSecurityGroup = new MenuItemSecurityGroup()
                {
                    SecurityGroupId = securityGroupId,
                    MenuItemId      = menuItem.Id,
                };

                _dbContext.MenuItemSecurityGroups.Add(menuItemSecurityGroup);
                _dbContext.SaveChanges();
            }
        }