Table of Contents | ||
---|---|---|
|
...
Create a single object
SDK-
...
Method
Code Block | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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; } } |
...