Amazon.CognitoSync.SyncManager.Internal.CognitoSyncStorage.PutRecordsAsync C# (CSharp) Method

PutRecordsAsync() public method

Post updates to remote storage. Each record has a sync count. If the sync count doesn't match what's on the remote storage, i.e. the record is modified by a different device, this operation throws ConflictException. Otherwise it returns a list of records that are updated successfully.
public PutRecordsAsync ( string datasetName, List records, string syncSessionToken, CancellationToken cancellationToken ) : Task>
datasetName string Dataset name.
records List Records.
syncSessionToken string Sync session token.
cancellationToken CancellationToken /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. ///
return Task>
        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);
            }
        }