Example #1
0
 // Set the Group ID of the Row to be inserted.
 // Has to be a Group of the user.
 public Insert SetGroupID(long groupID)
 {
     try
     {
         // Here we will Add the Group ID given by the User to the Statement.
         // Check if the Table is syncable, then only Add the row level security.
         if (CloudDB.IsSyncable(tableName))
         {
             // Lets validate if the User is allowed to write with this role.
             if (cdb.ValidateGroupRLS(groupID, CloudDB.CRUD.WRITE) || cdb.IsSystemUser)
             {
                 // The user is allowed to write with this role.
                 rlsType = C.RLS.GROUP_RLS;
                 rlsID   = groupID;
                 AddStatus("User is Authorized to Write in this Group");
                 return(this);
             }
             else
             {
                 // The user is not allowed to write with this role.
                 rlsType = C.RLS.NO_RLS;
                 rlsID   = 0;
                 isError = true;
                 AddStatus("User is NOT Authorized to Write in this Group");
                 return(this);
             }
         }
         else
         {
             // The table is not syncable, so we will not Add any RLS.
             rlsType = C.RLS.NO_RLS;
             rlsID   = 0;
             AddStatus("Table is not a Syncable Table.");
             return(this);
         }
     }
     catch (Exception e)
     {
         // There was an Error.
         rlsType = C.RLS.NO_RLS;
         rlsID   = 0;
         AddStatus("Error : " + e.Message);
         isError = true;
         return(this);
     }
 }