Exemplo n.º 1
0
        async Task CommitUpdateAsync(RecordItemChange change)
        {
            Debug.Assert(change.HasLocalData);

            if (await this.DetectDuplicateAsync(change))
            {
                // Already applied this change
                return;
            }

            try
            {
                change.UpdatedKey = await m_store.RemoteStore.PutAsync(change.LocalData);

                return;
            }
            catch (Exception ex)
            {
                if (!m_errorHandler.ShouldCreateNewItemForConflict(change, ex))
                {
                    //
                    // Let the calling function decide how to handle all other scenarios
                    //
                    throw;
                }
            }
            //
            // Conflict resolution is simple. We don't want to lose data. If the data on the server changed from underneath us,
            // we will write this item as a NEW one, since the user did actually take the trouble to create the entry
            //
            await this.CommitNewAsync(change);
        }