/// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.
            }
            else
            {
                noLabel = new LabelViewModel(new LabelMock() { Text = "No label" }, this);

                openNote = new OpenNoteCommand(this);
                newNote = new NewNoteCommand(this);
                closeNote = new CloseNoteCommand(this);
                deleteNote = new DeleteNoteCommand(this);
                saveNote = new SaveNoteCommand(this);
                delayedSaveNote = new DelayedSaveNoteCommand(this);
                simpleSearch = new SimpleSearchCommand(this);
                search = new ComplexSearchCommand(this);
                toggleSearch = new ToggleAdvancedSearchCommand(this);
                hideSearch = new HideSearchViewCommand(this);
                hideComplexSearch = new HideComplexSearchCommand(this);

                OpenNotes.CollectionChanged += openNotes_CollectionChanged;
                SearchResults.CollectionChanged += searchResults_CollectionChanged;
            }
        }
Example #2
0
        public NotesVM()
        {
            NewNoteCommand         = new NewNoteCommand(this);
            NewNotebookCommand     = new NewNotebookCommand(this);
            ExitCommand            = new ExitCommand(this);
            DeleteNoteCommand      = new DeleteNoteCommand(this);
            DeleteNotebookCommand  = new DeleteNotebookCommand(this);
            RenameNoteCommand      = new RenameNoteCommand(this);
            RenameNotebookCommand  = new RenameNotebookCommand(this);
            SaveNoteContentCommand = new SaveNoteContentCommand(this);

            Notes     = new ObservableCollection <Note>();
            Notebooks = new ObservableCollection <Notebook>();

            //TODO: Implement genuine login functionality.
            CurrentUser = new User()
            {
                Id        = 1,
                FirstName = "Alex",
                LastName  = "Barker",
                Username  = "******",
                Email     = "*****@*****.**",
                Password  = "******"
            };

            ReadNotebooks();
        }
        public async Task DeleteNoteCommandHandler_InvalidLaneId_ThrowsNotFoundException()
        {
            // Given
            var handler = new DeleteNoteCommandHandler(
                this.Context,
                Substitute.For <ISecurityValidator>(),
                Substitute.For <IMediator>()
                );

            var retro = new Retrospective {
                CurrentStage = RetrospectiveStage.Writing,
                FacilitatorHashedPassphrase = "whatever",
                Title             = TestContext.CurrentContext.Test.FullName,
                CreationTimestamp = DateTimeOffset.Now,
                Participants      = { new Participant {
                                          Name = "John"
                                      } }
            };
            string retroId = retro.UrlId.StringId;

            this.Context.Retrospectives.Add(retro);
            await this.Context.SaveChangesAsync();

            var command = new DeleteNoteCommand(retroId, -1);

            // When
            TestDelegate action = () => handler.Handle(command, CancellationToken.None).GetAwaiter().GetResult();

            // Then
            Assert.That(action, Throws.InstanceOf <NotFoundException>());
        }
Example #4
0
        public async Task Handle(DeleteNoteCommand command)
        {
            var id = command.Id;
            await noteRepository.Delete(id);

            notificationService.CancelScheduled(id);
            eventBus.Publish(new NoteDeletedEvent(id));
        }
Example #5
0
        public async Task <IActionResult> DeleteAsync(Guid id)
        {
            var cmd = new DeleteNoteCommand
            {
                Id = id
            };

            await DispatchAsync(cmd);

            return(Ok());
        }
 public WorkPageViewModel()
 {
     WPOpenProjectCommand = new WPOpenProjectCommand(this);
     BeginStopWorkCommand = new BeginStopWorkCommand(this);
     CompleteTaskCommand  = new CompleteTaskCommand(this);
     AddNoteCommand       = new AddNoteCommand(this);
     ToggleNotesCommand   = new ToggleNotesCommand();
     CloseProjectCommand  = new CloseProjectCommand(this);
     DeleteNoteCommand    = new DeleteNoteCommand();
     EditNoteCommand      = new EditNoteCommand(this);
 }
Example #7
0
 public NotesVM()
 {
     NewNoteCommand     = new NewNoteCommand(this);
     NewNotebookCommand = new NewNotebookCommand(this);
     Notebooks          = new ObservableCollection <Notebook>();
     Notes                 = new ObservableCollection <Note>();
     EditCommand           = new EditCommand(this);
     EndEditCommand        = new EndEditCommand(this);
     DeleteNotebookCommand = new DeleteNotebookCommand(this);
     DeleteNoteCommand     = new DeleteNoteCommand(this);
     IsVisible             = Visibility.Collapsed;
     GetNotebooks();
 }
        public async Task <IActionResult> DeleteAsync(DeleteNoteCommand command)
        {
            command.UserId = Guid.Parse(User.FindFirst(ClaimTypes.NameIdentifier)?.Value);
            var result = await _mediator.Send(command);

            if (!ModelState.IsValid)
            {
                return(BadRequest(new ErrorResource(result.Message)));
            }

            var notesResource = _mapper.Map <Note, NoteResource>(result.Note);

            return(Ok(notesResource));
        }
        public void DeleteNoteCommandHandler_InvalidRetroId_ThrowsNotFoundException()
        {
            // Given
            var handler = new DeleteNoteCommandHandler(
                this.Context,
                Substitute.For <ISecurityValidator>(),
                Substitute.For <IMediator>()
                );
            var command = new DeleteNoteCommand("not found", (int)KnownNoteLane.Start);

            // When
            TestDelegate action = () => handler.Handle(command, CancellationToken.None).GetAwaiter().GetResult();

            // Then
            Assert.That(action, Throws.InstanceOf <NotFoundException>());
        }
        public async Task DeleteNoteCommandHandler_ValidCommand_CreatesValidObjectAndBroadcast()
        {
            // Given
            var securityValidator = Substitute.For <ISecurityValidator>();
            var mediatorMock      = Substitute.For <IMediator>();
            var handler           = new DeleteNoteCommandHandler(
                this.Context,
                securityValidator,
                mediatorMock
                );

            var note = new Note {
                Retrospective = new Retrospective {
                    FacilitatorHashedPassphrase = "whatever",
                    CurrentStage = RetrospectiveStage.Writing,
                    Title        = this.GetType().FullName
                },
                Participant = new Participant {
                    Name = "Tester"
                },
                Lane = this.Context.NoteLanes.FirstOrDefault(),
                Text = "Derp"
            };

            TestContext.WriteLine(note.Retrospective.UrlId);
            this.Context.Notes.Add(note);
            await this.Context.SaveChangesAsync();

            var command = new DeleteNoteCommand(note.Retrospective.UrlId.StringId, note.Id);

            // When
            await handler.Handle(command, CancellationToken.None);

            // Then
            await securityValidator.Received().EnsureOperation(Arg.Is <Retrospective>(r => r.Id == note.Retrospective.Id), SecurityOperation.Delete, Arg.Any <Note>());

            var broadcastedNote = mediatorMock.ReceivedCalls().FirstOrDefault()?.GetArguments()[0] as NoteDeletedNotification;

            if (broadcastedNote == null)
            {
                Assert.Fail("No broadcast has gone out");
            }

            Assert.That(broadcastedNote.RetroId, Is.EqualTo(command.RetroId));
            Assert.That(broadcastedNote.LaneId, Is.EqualTo((int?)note.Lane?.Id));
            Assert.That(broadcastedNote.NoteId, Is.EqualTo(note.Id));
        }
Example #11
0
        public NotesVM()
        {
            IsEditing = false;

            NewNoteBookCommand    = new NewNotebookCommand(this);
            NewNoteCommand        = new NewNoteCommand(this);
            BeginEditCommand      = new BeginEditComand(this);
            HasEditedCommand      = new HasEditedCommand(this);
            DeleteNotebookCommand = new DeleteNotebookCommand(this);
            DeleteNoteCommand     = new DeleteNoteCommand(this);


            Notebooks = new ObservableCollection <Notebook>();
            Notes     = new ObservableCollection <Note>();
            ReadNotebooks();
            //  ReadNotes();
        }
Example #12
0
        public NotesViewModel()
        {
            IsEditedNotebook = false;

            NewNotebookCommand    = new NewNotebookCommand(this);
            NewNoteCommand        = new NewNoteCommand(this);
            beginEditCommand      = new BeginEditCommand(this);
            hasEditedCommand      = new HasEditedCommand(this);
            deleteNotebookCommand = new DeleteNotebookCommand(this);
            deleteNoteCommand     = new DeleteNoteCommand(this);

            Notebooks = new ObservableCollection <Notebook>();
            Notes     = new ObservableCollection <Note>();

            ReadNotebooks();
            ReadNote();
        }
Example #13
0
        public NotesWindowVM()
        {
            IsEditing = false;

            NewNoteBookCommand    = new NewNoteBookCommand(this);
            NewNoteCommand        = new NewNoteCommand(this);
            CloseProgramCommand   = new CloseProgramCommand(this);
            BeginEditCommand      = new BeginEditCommand(this);
            HasEditedCommand      = new HasEditedCommand(this);
            DeleteNoteBookCommand = new DeleteNoteBookCommand(this);
            DeleteNoteCommand     = new DeleteNoteCommand(this);

            Notebooks = new ObservableCollection <NoteBook>();
            Notes     = new ObservableCollection <Note>();

            SelectedNote = new Note();
            ReadNoteBooks();
            ReadNotes();
        }
Example #14
0
        public NotesVM()
        {
            IsEditing     = false;
            IsNoteEditing = false;

            NewNotebookCommand        = new NewNotebookCommand(this);
            NewNoteCommand            = new NewNoteCommand(this);
            RenameNoteBookCommand     = new RenameNoteBookCommand(this);
            HasNotebookRenamedCommand = new HasNotebookRenamedCommand(this);
            DeleteNotebookCommand     = new DeleteNotebookCommand(this);
            RenameNoteCommand         = new RenameNoteCommand(this);
            HasNoteRenamedCommand     = new HasNoteRenamedCommand(this);
            DeleteNoteCommand         = new DeleteNoteCommand(this);

            Notebooks = new ObservableCollection <NoteBook>();
            Notes     = new ObservableCollection <Note>();

            ReadNoteBooks();
            ReadNotes();
        }
        public MainViewModel()
        {
            ExitCommand     = new ExitCommand();
            NoteBookCommand = new NoteBookCommand(this);
            NoteCommand     = new NoteCommand(this);

            NoteBookCollection = new ObservableCollection <NoteBook>();
            NotesCollection    = new ObservableCollection <Notes>();
            //LoginVM loginvm = new LoginVM();
            LoginVM.HasLoggedIn    += Loginvm_HasLoggedIn;
            IsEditing               = false;
            IsEditingNote           = false;
            StartEditingCommand     = new StartEditingCommand(this);
            HasEditedCommand        = new HasEditedCommand(this);
            DeleteNoteCommand       = new DeleteNoteCommand(this);
            DeleteNoteBookCommand   = new DeleteNoteBookCommand(this);
            StartEditingNoteCommand = new StartEditingNoteCommand(this);
            HasEditedNoteCommand    = new HasEditedNoteCommand(this);

            //getNotes();
        }
Example #16
0
        public NotesVM()
        {
            IsEditing             = false;
            IsEditingNote         = false;
            NewNotebookCommand    = new NewNotebookCommand(this);
            NewNoteCommand        = new NewNoteCommand(this);
            DeleteNotebookCommand = new DeleteNotebookCommand(this);
            DeleteNoteCommand     = new DeleteNoteCommand(this);
            BeginEditCommand      = new BeginEditCommand(this);
            IsEditedCommand       = new IsEditedCommand(this);
            BeginEditNoteCommand  = new BeginEditNoteCommand(this);
            IsEditedNoteCommand   = new IsEditedNoteCommand(this);

            Notebooks = new ObservableCollection <Notebook>();
            Notes     = new ObservableCollection <Note>();
            FontSizes = new List <double>()
            {
                8, 9, 10, 11, 12, 14, 16, 28, 48, 72
            };

            ReadNotebooks();
            ReadNotes();
        }
 public Task HandleAsync(DeleteNoteCommand command)
 => _genericCommandHandler.DeleteAsync <NoteDto>(command.Id);
 public async Task <ActionResult <BoardViewModel> > Delete([FromBody] DeleteNoteCommand command)
 {
     return(Ok(await Mediator.Send(command)));
 }
        public MainVM()
        {
            if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject()))
            {
                Notes = new ObservableCollection <Note>();
                Notes.Add(new Note()
                {
                    Name = "note1", DateTime = DateTime.Now.ToShortDateString()
                });
                Notes.Add(new Note()
                {
                    Name = "note2", DateTime = DateTime.Now.ToShortDateString()
                });
                Notes.Add(new Note()
                {
                    Name = "note3", DateTime = DateTime.Now.ToShortDateString()
                });

                Pages = new ObservableCollection <Page>();
                Pages.Add(new Page()
                {
                    Name = "Screenshot", DateTime = DateTime.Now.ToShortDateString()
                });
                Pages.Add(new Page()
                {
                    Name = "Screenshot", DateTime = DateTime.Now.ToShortDateString()
                });
                Pages.Add(new Page()
                {
                    Name = "Screenshot", DateTime = DateTime.Now.ToShortDateString()
                });
                IsEditingNoteName = false;
                IsEditingVocab    = false;

                Vocabs = new ObservableCollection <Vocab>();
                Vocabs.Add(new Vocab()
                {
                    PageId = 1, Word = "123", Explaination = "321", Pronounciation = "aaa"
                });
                Vocabs.Add(new Vocab()
                {
                    PageId = 1, Word = "456", Explaination = "654", Pronounciation = "bbb"
                });
                Vocabs.Add(new Vocab()
                {
                    PageId = 1, Word = "789", Explaination = "987", Pronounciation = "ccc"
                });
            }
            else
            {
                WindowState                      = System.Windows.WindowState.Normal;
                NewNoteCommand                   = new NewNoteCommand(this);
                DeleteNoteCommand                = new DeleteNoteCommand(this);
                NewPageCommand                   = new NewPageCommand(this);
                DeletePageCommand                = new DeletePageCommand(this);
                RenameNoteCommand                = new RenameNoteCommand(this);
                ScreenCapCommand                 = new ScreenCapCommand(this);
                HasEditedNoteNameCommand         = new HasEditedNoteNameCommand(this);
                UsePreviousSelectionCommand      = new UsePreviousSelectionCommand(this);
                DoNotUsePreviousSelectionCommand = new DoNotUsePreviousSelectionCommand(this);
                CheckDictionaryCommand           = new CheckDictionaryCommand(this);
                GoogleTranslateCommand           = new GoogleTranslateCommand(this);
                DeleteVocabCommand               = new DeleteVocabCommand(this);
                NewVocabCommand                  = new NewVocabCommand(this);
                StartUpdateVocabCommand          = new StartUpdateVocabCommand(this);
                EndUpdateVocabCommand            = new EndUpdateVocabCommand(this);
                CropOriginalScreenshotCommand    = new CropOriginalScreenshotCommand(this);
                NewPageViaScreenshotCommand      = new NewPageViaScreenshotCommand(this);
                CaptureMoreTextCommand           = new CaptureMoreTextCommand(this);
                StartRenamePageCommand           = new StartRenamePageCommand(this);
                EndRenamePageCommand             = new EndRenamePageCommand(this);
                ToggleUpdateVocabCommand         = new ToggleUpdateVocabCommand(this);
                CheckDictionaryLittleDCommand    = new CheckDictionaryLittleDCommand(this);
                SyncVocabsCommand                = new SyncVocabsCommand(this);

                Notes  = new ObservableCollection <Note>();
                Pages  = new ObservableCollection <Page>();
                Vocabs = new ObservableCollection <Vocab>();
                ReadNotes();
                ReadPages();
                IsEditingNoteName              = false;
                IsEditingVocab                 = false;
                DisplayIndex                   = 0;
                DoUsePreviousSelection         = false;
                browserAddress                 = "";
                DictionaryBaseUrl_JapanDict    = "https://www.japandict.com/";
                DictionaryBaseUrl_littleD      = "http://dict.hjenglish.com/jp/jc/";
                SelectedPageIndex              = 0;
                NoPreviousCropButtonIsSelected = true;
                IsRenamingPage                 = false;
            }
        }