public async Task<List<Record>> PutRecordsAsync(string datasetName, List<Record> records, string syncSessionToken, CancellationToken cancellationToken)
{
UpdateRecordsRequest request = new UpdateRecordsRequest();
request.DatasetName = datasetName;
request.IdentityPoolId = identityPoolId;
request.IdentityId = this.GetCurrentIdentityId();
request.SyncSessionToken = syncSessionToken;
// create patches
List<RecordPatch> patches = new List<RecordPatch>();
foreach (Record record in records)
{
patches.Add(RecordToPatch(record));
}
request.RecordPatches = patches;
List<Record> updatedRecords = new List<Record>();
try
{
UpdateRecordsResponse updateRecordsResponse = await client.UpdateRecordsAsync(request, cancellationToken).ConfigureAwait(false);
foreach (Amazon.CognitoSync.Model.Record remoteRecord in updateRecordsResponse.Records)
{
updatedRecords.Add(ModelToRecord(remoteRecord));
}
return updatedRecords;
}
catch (Exception ex)
{
throw HandleException(ex, "Failed to update records in dataset: " + datasetName);
}
}