Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Current »

Create a single object

SDK-Method

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

REST-Equivalent

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

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

Task<MultiRequestItemStatusResult<TId>[]> BatchCreateAsync(
  params object[] entities
)

REST-Equivalent

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

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

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; }
}

  • No labels