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
{
	"ci_family_name": "Testikus",
	"ci_given_name": "Peter",
	"active": true,
	"tenant_id": 1,
	"core_identity_type.id": 1,
	"anonymization_status.id": 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
	{
		CiFamilyName = "Testikus",
		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
[
	{
		"ci_family_name": "Tester",
		"ci_given_name": "Peter",
		"active": true,
		"tenant_id": 1,
		"core_identity_type.id": 1,
		"anonymization_status.id": 1
	},
	{
		"ci_family_name": "Tester",
		"ci_given_name": "Hans",
		"active": true,
		"tenant_id": 1,
		"core_identity_type.id": 1,
		"anonymization_status.id": 1
	}
]

...

Example-Code

Code Block
languagec#
public async Task CreateCoreIdentities()
{
    var api = GetService<IApiV2Client>();
    var endpoint = api.DmcoreService.Servicedmcore.CoreIdentity;
    var results = await endpoint.BatchCreateAsync(new
	{
		CiFamilyName = "Tester",
		CiGivenName = "Peter",
		TenantId = 1,
		Active = true,
		CoreIdentityType = new
		{
			Id = 1
		},
		AnonymizationStatus = new
		{
			Id = 1
		}
	}, new
	{
		CiFamilyName = "Tester",
		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; }
}

...