예제 #1
0
        public void SelectNote(NoteModel obj)
        {
            _originActiveNote = obj;

            if (ActiveNote != null)
                ActiveNote.PropertyChanged -= ActiveNoteOnPropertyChanged;
            ActiveNote = new NoteModel()
            {
                Content = obj.Content,
                IsCompleted = obj.IsCompleted,
                CreateTime = obj.CreateTime,
                Description = obj.Description
            };
            if (ActiveNote != null)
                ActiveNote.PropertyChanged += ActiveNoteOnPropertyChanged;
        }
예제 #2
0
        public async Task TestNotes()
        {
            var note1 = new NoteModel()
            {
                IsCompleted = false,
                Content = "hallo welt",
                CreateTime = DateTime.Now,
                Guid = Guid.NewGuid()
            };
            var note2 = new NoteModel()
            {
                IsCompleted = false,
                Content = "hallo welt 1",
                CreateTime = DateTime.Today,
                Guid = Guid.NewGuid()
            };
            var note3 = new NoteModel()
            {
                IsCompleted = true,
                Content = "hallo welt 2",
                CreateTime = DateTime.Today - TimeSpan.FromDays(1),
                Guid = Guid.NewGuid()
            };
            var ds = new DataService();

            /*
            var addRequest = RequestConverter.Instance.ConvertToNoteRequest(ApiTestHelper.TestUserGuid,
                PossibleActions.Add, new List<NoteModel>() { note1, note2, note3 });
            var remove1 = RequestConverter.Instance.ConvertToNoteRequest(ApiTestHelper.TestUserGuid,
                PossibleActions.Delete, new List<NoteModel>() { note1 });
            var remove2 = RequestConverter.Instance.ConvertToNoteRequest(ApiTestHelper.TestUserGuid,
                PossibleActions.Delete, new List<NoteModel>() { note2, note3 });

            //act
            //check if 0 Notes
            var notes = await ds.GetNotes(ApiTestHelper.TestUserGuid);
            ApiAssertHelper.CheckBaseResponse(notes);
            Assert.IsTrue(notes.Notes == null || !notes.Notes.Any());

            //add Notes;
            var res = await ds.PostNote(addRequest);
            ApiAssertHelper.CheckBooleanResponse(res);

            //check if 2 Notes
            notes = await ds.GetNotes(ApiTestHelper.TestUserGuid);
            ApiAssertHelper.CheckBaseResponse(notes);
            Assert.IsTrue(notes.Notes != null && notes.Notes.Count == 3);

            //remove 1 Notes;
            res = await ds.PostNote(remove1);
            ApiAssertHelper.CheckBooleanResponse(res);

            //check if 2 Note, check Date
            notes = await ds.GetNotes(ApiTestHelper.TestUserGuid);
            ApiAssertHelper.CheckBaseResponse(notes);
            Assert.IsTrue(notes.Notes != null && notes.Notes.Count == 2);
            Assert.IsTrue(notes.Notes[0].Guid == note2.Guid);
            Assert.IsTrue(notes.Notes[0].CreateTime - note2.CreateTime < TimeSpan.FromSeconds(1));
            Assert.IsTrue(notes.Notes[1].Guid == note3.Guid);
            Assert.IsTrue(notes.Notes[1].CreateTime - note3.CreateTime < TimeSpan.FromSeconds(1));

            //remove 1 Note left;
            res = await ds.PostNote(remove2);
            ApiAssertHelper.CheckBooleanResponse(res);

            //check if 0 Notes
            notes = await ds.GetNotes(ApiTestHelper.TestUserGuid);
            ApiAssertHelper.CheckBaseResponse(notes);
            Assert.IsTrue(notes.Notes == null || !notes.Notes.Any());
            */
        }
예제 #3
0
        public Task<bool> Delete(NoteModel nm)
        {
            return ExecuteSafe(async () =>
            {
                await Initialize();

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

                if (nm.NoteCollection.CompletedNotes.Contains(nm))
                    nm.NoteCollection.CompletedNotes.Remove(nm);
                else if (nm.NoteCollection.NewNotes.Contains(nm))
                    nm.NoteCollection.NewNotes.Remove(nm);
                else if (nm.NoteCollection.DeletedNotes.Contains(nm))
                    nm.NoteCollection.DeletedNotes.Remove(nm);

                if (nm.PendingAction != PendingAction.None)
                    nm.NoteCollection.DeletedNotes.Add(nm);

                return await SaveNoteCollectionsToStorage() && res.IsSuccessfull;
            });
        }
예제 #4
0
 private void InsertIntoList(ObservableCollection<NoteModel> list, NoteModel model)
 {
     var found = false;
     for (int i = 0; i < list.Count; i++)
     {
         if (list[i].CreateTime < model.CreateTime)
         {
             list.Insert(i, model);
             found = true;
             break;
         }
     }
     if (!found)
         list.Add(model);
 }
예제 #5
0
        private void SelectNote(NoteModel note)
        {
            _navigationService.NavigateTo(PageKeys.NotePage.ToString());
            SimpleIoc.Default.GetInstance<NoteViewModel>().SelectNote(note);

            _activeCollection = note.NoteCollection;
            RaisePropertyChanged(() => ActiveCollection);
        }
예제 #6
0
 private async void RemoveNote(NoteModel note)
 {
     using (_removeNote.GetProgressDisposable(_progressService, ProgressKeys.SavingNote))
     {
         await _noteRepository.Delete(note);
         Messenger.Default.Send(Messages.NotesChanged);
     }
 }
예제 #7
0
 private async void ToggleCompleted(NoteModel note)
 {
     using (_toggleCompleted.GetProgressDisposable(_progressService, ProgressKeys.SavingNote))
     {
         note.IsCompleted = !note.IsCompleted;
         await _noteRepository.Save(note);
         Messenger.Default.Send(Messages.NotesChanged);
     }
 }
예제 #8
0
        private async void AddNote()
        {
            using (_addNoteCommand.GetProgressDisposable(_progressService, ProgressKeys.SavingNote))
            {
                var newNote = new NoteModel()
                {
                    Content = NewNote,
                    Guid = Guid.NewGuid(),
                    CreateTime = DateTime.Now,
                    NoteCollection = ActiveCollection
                };
                await _noteRepository.Save(newNote);
                NewNote = "";

                Messenger.Default.Send(Messages.NotesChanged);
            }
        }
예제 #9
0
 public async Task<bool> Delete(NoteModel nm)
 {
     return true;
 }
예제 #10
0
 public async Task<bool> Save(NoteModel nm)
 {
     return true;
 }