Click or drag to resize

ShareFactoryFindAllRules Method (IContext, ShareObjectType, IEnumerableIGroup, NullableInt32)

Find or calculate all the appropriate share rules for the specified object type and groups.

Namespace:  AskiaPortalCmn
Assembly:  AskiaPortalCmn (in AskiaPortalCmn.dll) Version: 1.7.0-build068
Syntax
public static IEnumerable<IShareRule> FindAllRules(
	IContext context,
	ShareObjectType objectType,
	IEnumerable<IGroup> groups,
	Nullable<int> surveyId = null
)

Parameters

context
Type: AskiaPortalCmnIContext
Context of execution.
objectType
Type: AskiaPortalCmnShareObjectType
Type of objects to find.
groups
Type: System.Collections.GenericIEnumerableIGroup
Contacts to find.
surveyId (Optional)
Type: SystemNullableInt32
Id of the survey, to scope the search.

Return Value

Type: IEnumerableIShareRule
Return the list of share rules
Remarks

The rules find could be database records or calculated rules.

Examples

Find all share rules for surveys.

var context = ContextFactory.CreateByUserGuid(Guid.Parse("20BE5F84-F006-49A0-9674-4B16A090AF2D"));   
var contextValidation = context.Validate();
if (!contextValidation.Success)
{
    throw contextValidation.Exception;
}

var groups = GroupFactory.FindAllByIds(context, context.User.Membership.GetIds());
var rules = ShareFactory.FindAllRules(context, ShareObjectType.Survey, groups);
foreach(var rule in rules)
{
    Console.WriteLine($@"The groups have the permission {rule.Permission} on the survey id `{rule.ObjectId}`");
}
See Also