Credential |
Create new credential.
Namespace: Gamanet.C4.SDK
Assembly: Gamanet.C4.SimpleClient (in Gamanet.C4.SimpleClient.dll) Version: 2026.0.0.733
Syntax
C#
public void Create( CredentialV1 credential )
Parameters
- credential CredentialV1
- The credential.
Implements
ISimpleClientCredentialRepositoryV1.Create(CredentialV1)Example
The following example illustrates how the SimpleClient creates card credential
The following example illustrates how the SimpleClient creates car licence plate credential
The following example illustrates how the SimpleClient creates PIN credential
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(); //you have to install package for credential type first //credential data var card = new CredentialV1( Guid.NewGuid(), credentialTypeId) // CredentialCategory.Card { Code = "0x457", Name = "Card 1", OwnerId = EntityRoot.Person, HolderId = personId, Status = CredentialStatus.Enabled }; client.Credentials.Create(card); // Verify that the credential is indeed created var result = client.Credentials.Get(card.Id); if(result != null) { Console.WriteLine(result.Name); } // Disconnect from server client.Disconnect(); } }
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(); //you have to install package for credential type first var carLicensePlate = new CredentialV1( Guid.NewGuid(), carLicencePlateId) { Code = "AA4444", Name = "CarLicensePlate 1", OwnerId = EntityRoot.Person, HolderId = personId, Status = CredentialStatus.Enabled }; client.Credentials.Create(carLicensePlate); // Verify that the credential is indeed created var result = client.Credentials.Get(carLicensePlate.Id); if (result != null) { Console.WriteLine(result.Name); } // Disconnect from server client.Disconnect(); } }
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(); //you have to install package for credential type first var newPin = new CredentialV1( Guid.NewGuid(), credentialTypeId) // 4 digits pin credential type { Code = "1234", Name = "Pin 1", HolderId = personId, Status = CredentialStatus.Enabled }; client.Credentials.Create(newPin); // Verify that the credential is indeed created var result = client.Credentials.Get(newPin.Id); if (result != null) { Console.WriteLine(result.Name); } // Disconnect from server client.Disconnect(); } }
See Also