コード例 #1
0
 private static void Relink(NoteCollectionModel model)
 {
     foreach (var completedNote in model.CompletedNotes)
     {
         completedNote.NoteCollection = model;
     }
     foreach (var deletedNote in model.DeletedNotes)
     {
         deletedNote.NoteCollection = model;
     }
     foreach (var noteModel in model.NewNotes)
     {
         noteModel.NoteCollection = model;
     }
 }
コード例 #2
0
        private async Task Initialize()
        {
            using (await _isInitializedLock.LockAsync())
            {
                if (_isInitialized)
                    return;

                _isInitialized = true;

                await ExecuteSafe(async () =>
                {
                    if (await RetrieveUserInformationsFromStorage())
                    {
                        await RetrieveNoteCollectionsFromStorage();
                    }
                    else
                    {
                        var coll = new NoteCollectionModel()
                        {
                            Name = "To do",
                            Guid = Guid.NewGuid(),
                            NewNotes = new ObservableCollection<NoteModel>()
                            {
                                new NoteModel()
                                {
                                    Guid = Guid.NewGuid(),
                                    IsCompleted = false,
                                    Content = "Add new Note",
                                    CreateTime = DateTime.Now,
                                    PendingAction = PendingAction.AddOrUpdate
                                },
                                new NoteModel()
                                {
                                    Guid = Guid.NewGuid(),
                                    IsCompleted = false,
                                    Content = "Install Application on my other Windows devices to sync notes",
                                    CreateTime = DateTime.Now,
                                    PendingAction = PendingAction.AddOrUpdate
                                }
                            },
                            CompletedNotes = new ObservableCollection<NoteModel>()
                            {
                                new NoteModel()
                                {
                                    Guid = Guid.NewGuid(),
                                    IsCompleted = true,
                                    Content = "Install to do application",
                                    CreateTime = DateTime.Now,
                                    PendingAction = PendingAction.AddOrUpdate
                                }
                            },
                            PendingAction = PendingAction.AddOrUpdate
                        };
                        NoteCollectionManager.AddNoteCollection(coll);
                    }
                });
            }

            await SyncNotes();
        }
コード例 #3
0
        public Task<bool> Delete(NoteCollectionModel nm)
        {
            return ExecuteSafe(async () =>
            {
                await Initialize();

                var obj = RequestConverter.Instance.ConvertToNoteCollectionRequest(_userInformations.Guid,
                    PossibleActions.Delete,
                    new List<NoteCollectionModel>() { nm });
                var res = await _dataService.PostNoteCollection(obj);
                nm.PendingAction = !res.IsSuccessfull ? PendingAction.Remove : PendingAction.None;

                NoteCollectionManager.RemoveFromCollection(nm);
                if (nm.PendingAction != PendingAction.None)
                    NoteCollectionManager.AddDeletedNoteCollection(nm);

                return await SaveNoteCollectionsToStorage() && res.IsSuccessfull;
            });
        }
コード例 #4
0
ファイル: MainViewModel.cs プロジェクト: famoser/RememberLess
        private void SelectNote(NoteModel note)
        {
            _navigationService.NavigateTo(PageKeys.NotePage.ToString());
            SimpleIoc.Default.GetInstance<NoteViewModel>().SelectNote(note);

            _activeCollection = note.NoteCollection;
            RaisePropertyChanged(() => ActiveCollection);
        }
コード例 #5
0
ファイル: MainViewModel.cs プロジェクト: famoser/RememberLess
 private async void SaveNoteCollection(NoteCollectionModel model)
 {
     using (_saveNoteCollection.GetProgressDisposable(_progressService, ProgressKeys.SavingNote))
     {
         await _noteRepository.Save(model);
     }
 }
コード例 #6
0
ファイル: MainViewModel.cs プロジェクト: famoser/RememberLess
 public bool CanSaveNoteCollection(NoteCollectionModel model)
 {
     return !string.IsNullOrEmpty(model?.Name);
 }
コード例 #7
0
ファイル: MainViewModel.cs プロジェクト: famoser/RememberLess
 private async void RemoveNoteCollection(NoteCollectionModel model)
 {
     using (_removeNoteCollection.GetProgressDisposable(_progressService, ProgressKeys.SavingNote))
     {
         if (model == ActiveCollection)
         {
             var index = NoteCollections.IndexOf(ActiveCollection);
             if (index == 0)
                 ActiveCollection = NoteCollections[1];
             else
                 ActiveCollection = NoteCollections[--index];
         }
         await _noteRepository.Delete(model);
         Messenger.Default.Send(Messages.NotesChanged);
     }
 }
コード例 #8
0
ファイル: MainViewModel.cs プロジェクト: famoser/RememberLess
 public bool CanRemoveNoteCollection(NoteCollectionModel model)
 {
     return NoteCollections.Count > 1;
 }
コード例 #9
0
ファイル: MainViewModel.cs プロジェクト: famoser/RememberLess
        private async void AddNoteCollection()
        {
            using (_addNoteCollectionCommand.GetProgressDisposable(_progressService, ProgressKeys.SavingNote))
            {
                var newNoteCollection = new NoteCollectionModel()
                {
                    Guid = Guid.NewGuid(),
                    Name = NewNoteCollection,
                    CreateTime = DateTime.Now
                };
                await _noteRepository.Save(newNoteCollection);
                NewNoteCollection = "";

                ActiveCollection = newNoteCollection;
            }
        }
コード例 #10
0
 public static void RemoveFromDeletedCollection(NoteCollectionModel model)
 {
     if (DeletedCollections.Contains(model))
         DeletedCollections.Remove(model);
 }
コード例 #11
0
 public static void RemoveFromCollection(NoteCollectionModel model)
 {
     if (Collections.Contains(model))
         Collections.Remove(model);
 }
コード例 #12
0
 public static void AddDeletedNoteCollection(NoteCollectionModel model)
 {
     Relink(model);
     DeletedCollections.Add(model);
 }
コード例 #13
0
 public static void TryAddNoteCollection(NoteCollectionModel model)
 {
     if (!Collections.Contains(model))
         AddNoteCollection(model);
 }
コード例 #14
0
 public async Task<bool> Delete(NoteCollectionModel nm)
 {
     return true;
 }