ShareFactoryFindAllRules Method (IContext, ShareObjectType, IUser, NullableInt32) |
Namespace: AskiaPortalCmn
public static IEnumerable<IShareRule> FindAllRules( IContext context, ShareObjectType objectType, IUser user, Nullable<int> surveyId = null )
This method return the more accurate shares.
- If the share is apply on the group and the user, the share of the user will be returned.
- The share apply on group closer to the user will be returned.
The rules find could be database records or calculated rules, specially for administrators.
A user that can manage a group is like a membership of that group.
Find all share rules for `survey`.
var context = ContextFactory.CreateByUserGuid(Guid.Parse("20BE5F84-F006-49A0-9674-4B16A090AF2D")); var contextValidation = context.Validate(); if (!contextValidation.Success) { throw contextValidation.Exception; } var user = UserFactory.FindById(context, 2); if (user == null) { Console.WriteLine("The specified user doesn't exist, or the current user within the context could not access it"); } var rules = ShareFactory.FindAllRules(context, ShareObjectType.Survey, user); foreach(var rule in rules) { Console.WriteLine($@"The user have the permission {rule.Permission} on the survey id `{rule.ObjectId}`"); }