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

Version 1 Next »

Einzelnes Objekt erstellen

SDK-Methode

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

REST-Equivalent

POST /servicedmcore/CoreIdentity
{
	"Nachname": "Testikus",
	"Vorname": "Peter",
	"Active": true,
	"TenantId": 1,
	"CoreIdentityType.Id": 1,
	"AnonymizationStatus.Id": 1
}

Beispiel-Code

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

Mehrere Objekte erstellen

SDK-Methode

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

REST-Equivalent

POST /servicedmcore/CoreIdentity
[
    {
        "Nachname": "Testikus",
        "Vorname": "Peter",
        "Active": true,
        "TenantId": 1,
        "CoreIdentityType.Id": 1,
        "AnonymizationStatus.Id": 1
    },
    {
        "Nachname": "Testikus",
        "Vorname": "Hans",
        "Active": true,
        "TenantId": 1,
        "CoreIdentityType.Id": 1,
        "AnonymizationStatus.Id": 1
    }
]

Beispiel-Code

public async Task CreateCoreIdentities()
{
    var api = GetService<IApiV2Client>();
    var endpoint = api.DmcoreService.Servicedmcore.CoreIdentity;
    var entityId = await endpoint.BatchCreateAsync(new
    {
        Nachname = "Testikus",
        Vorname = "Peter",
        TenantId = 1,
        Active = true,
        CoreIdentityType = new
        {
            Id = 1
        },
        AnonymizationStatus = new
        {
            Id = 1
        }
    }, new
    {
        Nachname = "Testikus",
        Vorname = "Hans",
        TenantId = 1,
        Active = true,
        CoreIdentityType = new
        {
            Id = 1
        },
        AnonymizationStatus = new
        {
            Id = 1
        }
    });
}

Antwort 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