Click or drag to resize

ShareFactoryFindAllRules Method (IContext, String, IEnumerableIGroup, NullableInt32, NullableGuid)

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,
	string objectType,
	IEnumerable<IGroup> groups,
	Nullable<int> surveyId = null,
	Nullable<Guid> moduleGuid = null
)

Parameters

context
Type: AskiaPortalCmnIContext
Context of execution.
objectType
Type: SystemString
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.
moduleGuid (Optional)
Type: SystemNullableGuid
GUID of the module that manage the objects (if null use the CurrentModule).

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 `template`.

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, "template", groups);
foreach(var rule in rules)
{
    Console.WriteLine($@"The groups have the permission {rule.Permission} on the template id `{rule.ObjectId}`");
}
See Also