// GET: /Admin/Menus/Details/5
        public ActionResult GetById(int id)
        {
            var item = _menuService.GetById(id);

            var model = new MenuJsonModel()
            {
                Id = item.Id,

                Name = item.Name,

                Link = item.Link,
            };

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 菜单树内部子节点的递归方法
        /// </summary>
        /// <param name="menuItem">当前父级菜单</param>
        /// <param name="menudata">子菜单集合</param>
        private static void RecursiveBuilder(MenuJsonModel menuItem, List <MenuJsonModel> menudata)
        {
            var menuItems = menudata.Where(menu => menu.ParentIdentifyCode == menuItem.IdentifyCode).ToList();

            if (!menuItems.Any())
            {
                return;
            }
            foreach (var item in menuItems)
            {
                //item.ParentId = menuItem.Id;
                item.Text = item.Name;
                menuItem.Children.Add(item);
                RecursiveBuilder(item, menudata);
            }
        }