Example #1
0
    protected void btnGrantAccess_Click(object sender, EventArgs e)
    {
        List <PermissionMap> permissionList = new List <PermissionMap>();

        foreach (GridViewRow item in grdVwPermission.Rows)
        {
            PermissionMap pm = new PermissionMap();
            pm.Permission = ((Label)item.FindControl("lblPermission")).Text;
            pm.Allow      = ((CheckBox)item.FindControl("chkGrantPermission")).Checked;
            pm.Deny       = ((CheckBox)item.FindControl("chkRevokePermission")).Checked;
            permissionList.Add(pm);
        }

        bool result = false;

        using (ResourceDataAccess dataAccess = new ResourceDataAccess(Utility.CreateContext()))
        {
            result = dataAccess.SetPermissionToResource(ResourceId, permissionList,
                                                        UserOrGroupId,
                                                        userToken);
        }

        if (PermissionGranted != null)
        {
            PermissionGranted(sender, new GrantEventArgs(result));
        }
    }