Example #1
0
 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();
 }
Example #2
0
 private void ToFind()
 {
     db = new DataBaseModel();
     ClearCollections();
     if (CustomCommands.IsFilled(WordToFind) == true)
     {
         GetFromDb();
     }
     else
     {
         MessageBox.Show("Write a word to find");
     }
 }
Example #3
0
 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();
 }
Example #4
0
 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);
         }
     }
 }
Example #5
0
 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);
         }
     }
 }
Example #6
0
 public static void RemoveBooks(AuthorModel SelectedAuthor, List <BookModel> newbooks, DataBaseModel DbContext)
 {
     foreach (BookModel newbook in newbooks)
     {
         SelectedAuthor.books.Remove(DbContext.books.Find(newbook.Id));
     }
 }
Example #7
0
 public static void RemoveAuthors(BookModel SelectedBook, List <AuthorModel> newauthors, DataBaseModel DbContext)
 {
     foreach (AuthorModel newauthor in newauthors)
     {
         SelectedBook.authors.Remove(DbContext.authors.Find(newauthor.Id));
     }
 }