Exemple #1
0
        public async Task <bool> SyncUpsertFolderAsync(SyncFolderNotification notification, bool isEdit)
        {
            SyncStarted();
            if (await _stateService.IsAuthenticatedAsync())
            {
                try
                {
                    var localFolder = await _folderService.GetAsync(notification.Id);

                    if ((!isEdit && localFolder == null) ||
                        (isEdit && localFolder != null && localFolder.RevisionDate < notification.RevisionDate))
                    {
                        var remoteFolder = await _apiService.GetFolderAsync(notification.Id);

                        if (remoteFolder != null)
                        {
                            var userId = await _stateService.GetActiveUserIdAsync();

                            await _folderService.UpsertAsync(new FolderData(remoteFolder, userId));

                            _messagingService.Send("syncedUpsertedFolder", new Dictionary <string, string>
                            {
                                ["folderId"] = notification.Id
                            });
                            return(SyncCompleted(true));
                        }
                    }
                }
                catch { }
            }
            return(SyncCompleted(false));
        }
Exemple #2
0
        public async Task <bool> SyncDeleteFolderAsync(SyncFolderNotification notification)
        {
            SyncStarted();
            if (await _stateService.IsAuthenticatedAsync())
            {
                await _folderService.DeleteAsync(notification.Id);

                _messagingService.Send("syncedDeletedFolder", new Dictionary <string, string>
                {
                    ["folderId"] = notification.Id
                });
                return(SyncCompleted(true));
            }
            return(SyncCompleted(false));
        }