Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
maxLevel2

...

Create a single object

SDK-

...

Method

Code Block
languagec#
Task<TId> IApiV2Endpoint<TId>.CreateAsync(
  object entity, 
  CancellationToken cancellationToken = default
)

REST-Equivalent

Code Block
POST /servicedmcore/CoreIdentity
{
	"Nachnameci_family_name": "Testikus",
	"Vornameci_given_name": "Peter",
	"Activeactive": true,
	"TenantIdtenant_id": 1,
	"CoreIdentityType.Idcore_identity_type.id": 1,
	"AnonymizationStatusanonymization_status.Idid": 1
}

...

Example-Code

Code Block
languagec#
public async Task CreateCoreIdentity()
{
    	var api = GetService<IApiV2Client>();
    	var endpoint = api.DmcoreService.Servicedmcore.CoreIdentity;
    	var entityId = await endpoint.CreateAsync(new
    {
        Nachname	{
		CiFamilyName = "Testikus",
        Vorname 		CiGivenName = "Peter",
        		TenantId = 1,
        		Active = true,
        		CoreIdentityType = new
        {
            		{
			Id = 1
        		},
        		AnonymizationStatus = new
        {
            		{
			Id = 1
        		}
    	});
}

...

Create multiple objects

SDK-

...

Method

Code Block
languagec#
Task<MultiRequestItemStatusResult<TId>[]> BatchCreateAsync(
  params object[] entities
)

REST-Equivalent

Code Block
POST /servicedmcore/CoreIdentity
[
    	{
        "Nachname		"ci_family_name": "TestikusTester",
        "Vorname		"ci_given_name": "Peter",
        "Active		"active": true,
        "TenantId		"tenant_id": 1,
        "CoreIdentityType.Id		"core_identity_type.id": 1,
        "AnonymizationStatus.Id		"anonymization_status.id": 1
    	},
    	{
        "Nachname		"ci_family_name": "TestikusTester",
        "Vorname		"ci_given_name": "Hans",
        "Active		"active": true,
        "TenantId		"tenant_id": 1,
        "CoreIdentityType.Id		"core_identity_type.id": 1,
        "AnonymizationStatus.Id		"anonymization_status.id": 1
    	}
]

...

Example-Code

Code Block
languagec#
public async Task CreateCoreIdentities()
{
    var api = GetService<IApiV2Client>();
    var endpoint = api.DmcoreService.Servicedmcore.CoreIdentity;
    var entityIdresults = await endpoint.BatchCreateAsync(new
    {
        Nachname	{
		CiFamilyName = "TestikusTester",
        Vorname 		CiGivenName = "Peter",
        		TenantId = 1,
        		Active = true,
        		CoreIdentityType = new
        {
            		{
			Id = 1
        		},
        		AnonymizationStatus = new
        {
            		{
			Id = 1
        		}
    	}, new
    {
        Nachname 	{
		CiFamilyName = "TestikusTester",
        Vorname 		CiGivenName = "Hans",
        		TenantId = 1,
        		Active = true,
        		CoreIdentityType = new
        {
            		{
			Id = 1
        		},
        		AnonymizationStatus = new
        {
            		{
			Id = 1
		}
	});
	var newIds = results.Select(e   }
    }=> e.Id).ToArray();
}

...

Answer DataContracts

Code Block
languagec#
public class MultiRequestItemStatusResult<TId>
{
    /// <summary>
    /// The objects Identifier
    /// </summary>
    public TId Id { get; set; }
    
    /// <summary>
    /// Success or Error
    /// </summary>
    public ObjectStatus StatusType { get; set; }

    /// <summary>
    /// The ErrorObject if there was an error
    /// <see cref="iTsense.Moving.Common.ApiV2.Client.ApiV2Exception"/>
    /// </summary>
    public object Value { get; set; }
}

...