Ejemplo n.º 1
0
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Edit(string id)
        {
            var list = bll.GetAllList().Where(m => m.ParentId == "0").ToList();//获取一级权限列表

            ViewBag.list = list;
            T_Permissions model = bll.GetById(id);

            return(View(model));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 当前用户拥有权限
        /// </summary>
        /// <returns></returns>
        protected List <PerssionModel> GetPermissions()
        {
            HttpCookie _cookie = CookieHelper.GetCookie("User");
            var        result  = new  List <PerssionModel>();

            if (_cookie["UserId"] != null)
            {
                var           perssionlist = baseservice.GetPermissions(_cookie["UserId"].ToString());//子权限
                List <string> pids         = perssionlist.Select(m => m.ParentId).Distinct().ToList();
                foreach (var item in pids)
                {
                    result.Add(new PerssionModel {
                        ParentPermissions = perssionbll.GetById(item),
                        childrenList      = perssionlist.Where(m => m.ParentId == item).ToList()
                    });
                }
                return(result);
            }
            else
            {
                return(null);
            }
        }