public override int GetHashCode() { var hashCode = base.GetHashCode(); hashCode += 27 * Negation.GetHashCode(); hashCode += 27 * RightOperation.GetHashCode(); return(hashCode); }
public bool RoleHasRight(string roleName, Rights right, RightOperation rightOperation) { var userRole = UserRole.GetByName(roleName); foreach (BORoleRightX roleRight in userRole.RoleRights) { if (roleRight.Right.ID == (long)right) { switch (rightOperation) { case RightOperation.Any: return roleRight.CanCreate || roleRight.CanDelete || roleRight.CanExecute || roleRight.CanRead || roleRight.CanUpdate; case RightOperation.Create: return roleRight.CanCreate; case RightOperation.Delete: return roleRight.CanDelete; case RightOperation.Execute: return roleRight.CanExecute; case RightOperation.Read: return roleRight.CanRead; case RightOperation.Update: return roleRight.CanUpdate; default: return false; } } } return false; }
public bool UserHasRight(string userName, Rights right, RightOperation rightOperation) { IEnumerable<BORole> roles = UserRoles(BOUser.GetByGUID(Membership.GetUser(userName).ProviderUserKey.ToString())); foreach (var role in roles) { if (RoleHasRight(role.Name, right, rightOperation)) return true; } return false; }
public bool RoleHasRight(string roleName, Rights permission, RightOperation operation) { BORole userRole = GetRole(roleName); IEnumerable<BORoleRightX> roleRights = GetRoleRights(userRole); foreach (var roleRight in roleRights) { if (roleRight.Right.ID == (long)permission) { switch (operation) { case RightOperation.Any: return roleRight.CanCreate || roleRight.CanDelete || roleRight.CanExecute || roleRight.CanRead || roleRight.CanUpdate; case RightOperation.Create: return roleRight.CanCreate; case RightOperation.Delete: return roleRight.CanDelete; case RightOperation.Execute: return roleRight.CanExecute; case RightOperation.Read: return roleRight.CanRead; case RightOperation.Update: return roleRight.CanUpdate; default: return false; } } } return false; }