ValidateWithPermissionIndex method

void ValidateWithPermissionIndex(
  1. bool isCalendarFolder,
  2. int permissionIndex
)
Validates this instance. if set to calendar permissions are allowed. Index of the permission.

Implementation

void ValidateWithPermissionIndex(bool isCalendarFolder, int permissionIndex) {
  // Check property.UserId
  if (!this._userId!.IsValid()) {
    throw new ServiceValidationException("""string.Format(
                      Strings.FolderPermissionHasInvalidproperty.UserId,
                      permissionIndex)""");
  }

  // If this permission is to be used for a non-calendar folder make sure that read access and permission level aren't set to Calendar-only values
  if (!isCalendarFolder) {
    if ((this._readItems ==
            FolderPermissionReadAccess.TimeAndSubjectAndLocation) ||
        (this._readItems == FolderPermissionReadAccess.TimeOnly)) {
      throw new ServiceLocalException("""string.Format(
                          Strings.ReadAccessInvalidForNonCalendarFolder,
                          this.readItems""");
    }

    if ((this._permissionLevel ==
            FolderPermissionLevel.FreeBusyTimeAndSubjectAndLocation) ||
        (this._permissionLevel == FolderPermissionLevel.FreeBusyTimeOnly)) {
      throw new ServiceLocalException("""string.Format(
                          Strings.PermissionLevelInvalidForNonCalendarFolder,
                          this.permissionLevel)""");
    }
  }
}