Exemplo n.º 1
0
        /// <summary>
        /// Adds a permission to this role instance.
        /// </summary>
        /// <param name="permission">The permission to add.</param>
        public void AddPermission(Permission permission)
        {
            var rolePermission = new RolePermission
            {
                Permission = permission,
                Role       = this
            };

            RolePermissions.Add(rolePermission);
        }
Exemplo n.º 2
0
        private void SavePermissions(string roleName)
        {
            RolePermissions        roleController = new RolePermissions();
            List <RolePermissions> list           = roleController.GetByRolePermissionName(roleName);

            if (list != null)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    RolePermissions role = list[i];
                    roleController.Delete(role.RolePermissionID);
                }
                list.Clear();
            }
            else
            {
                list = new List <RolePermissions>();
            }

            foreach (GridViewRow row in permissionGridView.Rows)
            {
                CheckBox accessableCheckBox = (CheckBox)row.FindControl("accessableCheckBox");
                if (accessableCheckBox == null || !accessableCheckBox.Checked)
                {
                    continue;
                }

                RolePermissions item = new RolePermissions();
                item.RoleName   = roleName;
                item.PageName   = row.Cells[0].Text;
                item.Accessable = accessableCheckBox.Checked;

                list.Add(item);
                roleController.Add(item);
            }

            UpdateAllowedPagesInSession(list, roleName);
        }
 /// <summary>
 /// Adds a role permission to the current folder
 /// </summary>
 /// <param name="role"></param>
 /// <param name="accessPerm"></param>
 public void AddRolePermission(string role, AccessPermissionEnum accessPerm)
 {
     RolePermissions.Add(new RolePermission(role, accessPerm));
 }
Exemplo n.º 4
0
Arquivo: Role.cs Projeto: zxbe/Columbo
 public void AddPermissions(List <int> permissionsId, int creatorId)
 {
     //todo sprawdzanie duplikatów
     permissionsId.ForEach(x => RolePermissions.Add(new RolePermission(creatorId, this.Id, x)));
 }