private void SaveBook(List <AuthorModel> newauthors) { using (DataBaseModel db1 = new DataBaseModel()) { CustomCommands.AddAuthors(SelectedBook, newauthors, db1); db1.books.Add(SelectedBook); db1.SaveChanges(); } MessageBox.Show("Saved succsessfully"); SelectedBook.Genre = null; SelectedBook.Title = null; SelectedBook.authors.Clear(); }
private void ToFind() { db = new DataBaseModel(); ClearCollections(); if (CustomCommands.IsFilled(WordToFind) == true) { GetFromDb(); } else { MessageBox.Show("Write a word to find"); } }
private void SaveAuthor(List <BookModel> newbooks) { using (DataBaseModel db1 = new DataBaseModel()) { CustomCommands.AddBooks(SelectedAuthor, newbooks, db1); db1.authors.Add(SelectedAuthor); db1.SaveChanges(); } MessageBox.Show("Saved succsessfully"); SelectedAuthor.Name = null; SelectedAuthor.Surname = null; SelectedAuthor.books.Clear(); }
public BookViewModel() { this.CloseWindowCommand = new RelayCommand <Window>(CustomCommands.CloseWindow); this.SaveListCommand = new RelayCommand <object>(GetFromList); authors = new ObservableCollection <AuthorModel>(); this.SelectedBook = new BookModel(); using (DataBaseModel db = new DataBaseModel()) { foreach (AuthorModel newauthor in db.authors) { authors.Add(newauthor); } } }
public AuthorViewModel() { this.CloseWindowCommand = new RelayCommand <Window>(CustomCommands.CloseWindow); this.SaveListCommand = new RelayCommand <object>(GetFromList); this.SelectedAuthor = new AuthorModel(); books = new ObservableCollection <BookModel>(); using (DataBaseModel db = new DataBaseModel()) { foreach (BookModel newbook in db.books) { books.Add(newbook); } } }
public static void RemoveBooks(AuthorModel SelectedAuthor, List <BookModel> newbooks, DataBaseModel DbContext) { foreach (BookModel newbook in newbooks) { SelectedAuthor.books.Remove(DbContext.books.Find(newbook.Id)); } }
public static void RemoveAuthors(BookModel SelectedBook, List <AuthorModel> newauthors, DataBaseModel DbContext) { foreach (AuthorModel newauthor in newauthors) { SelectedBook.authors.Remove(DbContext.authors.Find(newauthor.Id)); } }