Esempio n. 1
0
        private PermissionModel CreatePermissionModel(AdminPermissionModel item, List <AdminPermissionModel> list, IdentityManager.RoleType roleType)
        {
            bool check    = false;
            bool disabled = false;
            bool visible  = true;

            if (list != null)
            {
                var t = list.FirstOrDefault(p => p.Id == item.Id);
                if (t != null || roleType == IdentityManager.RoleType.SuperAdmin)
                {
                    check = true;
                }
            }
            // Q101是后台管理人员必须要拥有的权限,所以添加一个后台管理人员,那么这个权限必须要有
            if (item.Id == "Q101")
            {
                check    = true;
                disabled = true;
                visible  = false;
            }
            var per = new PermissionModel()
            {
                Title    = item.Name,
                Value    = item.Id,
                Checked  = check,
                Disabled = disabled,
                Visible  = visible,
                Data     = new List <PermissionModel>()
            };

            return(per);
        }
Esempio n. 2
0
        private void GetPermissionModels(PermissionModel permission, AdminPermissionModel item, List <AdminPermissionModel> list, List <AdminPermissionModel> all, IdentityManager.RoleType roleType)
        {
            var subList = all.Where(p => p.ParentId == item.Id);

            if (subList.Count() > 0)
            {
                foreach (var sub in subList)
                {
                    var per = CreatePermissionModel(sub, list, roleType);
                    permission.Data.Add(per);
                    if (all.Where(p => p.ParentId == sub.Id).Count() > 0)
                    {
                        GetPermissionModels(per, sub, list, all, roleType);
                    }
                }
            }
        }