Permission |
Creates new permission.
Namespace: Gamanet.C4.SDK
Assembly: Gamanet.C4.SimpleClient (in Gamanet.C4.SimpleClient.dll) Version: 2026.0.0.733
Syntax
C#
public void Create( PermissionV1 permission )
Parameters
- permission PermissionV1
- The permission.
Implements
ISimpleClientPermissionRepositoryV1.Create(PermissionV1)Exceptions
| Exception | Condition |
|---|---|
| ValidationException |
Example
The following example illustrates how the SimpleClient creates permission. Access permission for person to device door
C#
using System; using Gamanet.C4.SDK; using Gamanet.C4.SimpleInterfaces; public class Example { static void Main() { // Create instance of simple client var client = new SimpleClient(ConnectorConfiguration.HttpClient); ConnectionInfoV1 token; // Connect to local server var connectionResult = client.Connect(new Uri("https://localhost/"), "Support", "support", out token); if (connectionResult != ConnectionResult.Successful) { Console.WriteLine("Connection unsuccessful, result: {0}", connectionResult); return; } Console.WriteLine("Connection result: {0}", connectionResult); Console.WriteLine(); var permission = new PermissionV1( Guid.NewGuid(), //permission Id PermissionType.AccessEntry, // what permission person.Id, // who will be permitted door.Id, // where is permission applied EntityType.Devices); //what is root permission type permission.Status = PermissionStatus.Allowed; // Create permission in database client.Permissions.Create(permission); // Verifyy that the permission has been created var result = client.Permissions.Get(permission.Id); Console.WriteLine(result != null ? "Permission created" : "Permission was not created"); // Disconnect from server client.Disconnect(); } }
See Also