Esempio n. 1
0
        public BookVM AddBookExternal(BookRelation relation)
        {
            BookVM newBook = AddOrEditBook(null, relation);

            if (newBook != null)
            {
                using (UndoTransaction tx = new UndoTransaction(UndoManager))
                {
                    books.Add(newBook);
                    StudyUnit.OnRemoveBooks();
                    tx.Commit();
                }
            }
            return(newBook);
        }
Esempio n. 2
0
 public void RemoveBookExternal(BookVM targetBook)
 {
     if (targetBook == null)
     {
         return;
     }
     using (UndoTransaction tx = new UndoTransaction(UndoManager))
     {
         books.Remove(targetBook);
         StudyUnit.OnRemoveBooks();
         tx.Commit();
     }
     if (SelectedBook == targetBook)
     {
         SelectedBookItem = null;
     }
 }
Esempio n. 3
0
        public BookVM SelectBookExternal(BookRelation relation)
        {
            SelectObjectWindowVM <BookVM> vm     = new SelectObjectWindowVM <BookVM>(books);
            SelectObjectWindow            window = new SelectObjectWindow(vm);
            BookVM book = SelectObjectWindow.Select(Resources.SelectBook, vm) as BookVM; //Select

            if (book != null)
            {
                using (UndoTransaction tx = new UndoTransaction(UndoManager))
                {
                    if (book.Book.FindRelation(relation) == null)
                    {
                        //Need not be generated here since ViewModel Since is re-generated every time EditBookWindow is displayed.
                        book.Book.BookRelations.Add(relation);
                    }
                    StudyUnit.OnRemoveBooks();
                    tx.Commit();
                }
            }
            return(book);
        }
Esempio n. 4
0
        public BookVM EditBookExternal(BookVM targetBook)
        {
            if (targetBook == null)
            {
                return(null);
            }
            BookVM newBook = AddOrEditBook(targetBook.Book, null);

            if (newBook != null)
            {
                using (UndoTransaction tx = new UndoTransaction(UndoManager))
                {
                    int index = books.IndexOf(targetBook);
                    books.RemoveAt(index);
                    books.Insert(index, newBook);
                    StudyUnit.OnRemoveBooks();
                    tx.Commit();
                }
            }
            return(newBook);
        }