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); }
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; } }
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); }
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); }