CredentialRepository.CanCreateCredential Method

Determines whether can create the specified credential.

Namespace: Gamanet.C4.SDK
Assembly: Gamanet.C4.SimpleClient (in Gamanet.C4.SimpleClient.dll) Version: 2026.0.0.733
Syntax
C#
public bool CanCreateCredential(
	CredentialV1 credential
)

Parameters

credential  CredentialV1
The credential.

Return Value

Boolean
true if credential can be created and is valid, otherwise false.

Implements

ISimpleClientCredentialRepositoryV1.CanCreateCredential(CredentialV1)
Example
The following example illustrates how SimpleClient checks if a credential is valid and can 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();

        // create new pin credential
        var credentialTypeId = pin4credentialTypeId; // Id card type in C4 Client
        var newCredential = new CredentialV1(Guid.NewGuid(), credentialTypeId);
        newCredential.Code = "1111";
        newCredential.Status = CredentialStatus.Enabled;
        newCredential.HolderId = personId; // real person id

        // checking with this method can prevent duplicity card code, PIN code, ...
        var canBeCreated = client.Credentials.CanCreateCredential(newCredential);

        Console.WriteLine(canBeCreated.ToString());

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

Reference

CredentialRepository Class
Gamanet.C4.SDK Namespace