public void OpenWindowBookMethod() { if (CheckBook()) { if (AuthorsOfBook.Count != 0) { AuthorsOfBook.Clear(); } using (Model1 context = new Model1()) { ObservableCollection <Author> Authors = context.Books.Where(c => (c.BookName == BookName)).Select(c => c.Authors).FirstOrDefault(); foreach (Author a in Authors) { AuthorsOfBook.Add(new AuthorViewModel() { SecondName = a.SecondName, FirstName = a.FirstName, FatherName = a.FatherName }); } } NameOfBook = BookName; SelectedAuthor = null; WindowBooks WindowNew = new WindowBooks(); WindowNew.ShowDialog(); } else { MessageBox.Show("Книга не найдена"); } }
public void AddAuthorToBookMethod() { AuthorsOfBook.Add(SelectedAuthor); if (CheckAuthor() == false) { AddAuthorMethod(); } Add(NameOfBook, SelectedAuthor); }
public void DeleteAuthorFromBookMethod() { Boolean proverca = false; foreach (AuthorViewModel b in AuthorsOfBook) { if ((b.SecondName == SelectedAuthor.SecondName) & (b.FatherName == SelectedAuthor.FatherName) & (b.FirstName == SelectedAuthor.FirstName)) { proverca = true; } } if (proverca == true) { Delete(NameOfBook, SelectedAuthor); AuthorsOfBook.Remove(SelectedAuthor); } else { MessageBox.Show("Автор в списке отсутствует"); } }