public void TestBook() { using (LibraryDb db = LibraryDb.GetDbContext()) { var books = BooksBl.GetBooks(); //add book test BOOK book = new BOOK { ISBN = "test", COUNT = 0, NAME = "test", PRICE = 0 }; BooksBl.AddNewCard(book); BOOK dbBook = db.BOOKS.SingleOrDefault(b => b.ID == book.ID); Assert.IsNotNull(dbBook); //Change book test dbBook.DESCRIPTION = someText; BooksBl.UpdateBook(dbBook); dbBook = db.BOOKS.SingleOrDefault(b => b.ID == book.ID); Assert.AreEqual(true, dbBook?.DESCRIPTION == someText); //deleted test book BooksBl.BooksRemove(new[] { book.ID }); dbBook = db.BOOKS.SingleOrDefault(b => b.ID == book.ID); Assert.IsNull(dbBook); } }
private void RefreshBooks() { ThreadPool.QueueUserWorkItem(obj => { try { this.GuiSync(() => { dgBooks.ItemsSource = null; dgBooks.ItemsSource = BooksBl.GetBooks(); }); } catch (Exception ex) { this.GuiSync(() => MessageBox.Show(ex.Message, "Не удалось обновить таблицу!", MessageBoxButton.OK, MessageBoxImage.Error)); } }); }
public void AddNewRow(BOOK book) { BooksBl.AddNewCard(book); }
public void RemoveRow(BOOK book) { BooksBl.BooksRemove(new[] { book.ID }); }
public void UpdateRow(BOOK book) { BooksBl.UpdateBook(book); }