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 (!_userId!.IsValid()) {
    throw 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 ((_readItems ==
            FolderPermissionReadAccess.TimeAndSubjectAndLocation) ||
        (_readItems == FolderPermissionReadAccess.TimeOnly)) {
      throw ServiceLocalException("""string.Format(
                          Strings.ReadAccessInvalidForNonCalendarFolder,
                          this.readItems""");
    }

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