PermissionRepository.Import Method

Import the list of permissions. If a permission already exists, they will be updated and if they do not exist, they will be created.

Namespace: Gamanet.C4.SDK
Assembly: Gamanet.C4.SimpleClient (in Gamanet.C4.SimpleClient.dll) Version: 2026.0.0.733
Syntax
C#
public void Import(
	ISimpleCollection<PermissionV1> permissions
)

Parameters

permissions  ISimpleCollection<PermissionV1>
The permissions.

Implements

ISimpleClientPermissionRepositoryV1.Import(ISimpleCollection<PermissionV1>)
Exceptions
ExceptionCondition
ValidationException
Example
If a permission already exists, they will be updated and if they do not exist, they will be created.
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 examplePermissionToUpdate = new PermissionV1(
            Guid.NewGuid(), //permission Id
            PermissionType.AccessEntry, // what permission
            EntityRoot.Person, // who will be permitted
            EntityRoot.Device, // where is permission applied
            EntityType.Devices); //what is root permission type

        // Create permission in database
        client.Permissions.Create(examplePermissionToUpdate);

        // Modift permission Type
        examplePermissionToUpdate.PermissionType = PermissionType.Read;

        var examplePermissionToCreate = new PermissionV1(
            Guid.NewGuid(), //permission Id
            PermissionType.AccessEntry, // what permission
            EntityRoot.Person, // who will be permitted
            EntityRoot.Device, // where is permission applied
            EntityType.Devices); //what is root permission type

        var examplePermissionToImport = new SimpleCollection<PermissionV1>
        {
            examplePermissionToUpdate, examplePermissionToCreate
        };

        // Here we print out permission IDs, so we can later check them againt the result
        Console.WriteLine($"PermissionToUpdate: {examplePermissionToUpdate.Id}\nPermissionToCreate: {examplePermissionToCreate.Id}");
        // importing the permissions
        client.Permissions.Import(examplePermissionToImport);

        // Getting all permissions and checking the result
        var result = client.Permissions.GetAll();
        foreach ( var item in result)
        {
            if (item.Id == examplePermissionToCreate.Id)
                Console.WriteLine($"{item.Id} <- this is permission created by import");
            else if (item.Id == examplePermissionToUpdate.Id)
                Console.WriteLine($"{item.Id} <- this is permission updated by import.");
            else
                Console.WriteLine(item.Id);
        }

        // Disconnect from server
        client.Disconnect();
    }
}
See Also

Reference

PermissionRepository Class
Gamanet.C4.SDK Namespace