Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
 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));
         }
     });
 }
Beispiel #3
0
 public void AddNewRow(BOOK book)
 {
     BooksBl.AddNewCard(book);
 }
Beispiel #4
0
 public void RemoveRow(BOOK book)
 {
     BooksBl.BooksRemove(new[] { book.ID });
 }
Beispiel #5
0
 public void UpdateRow(BOOK book)
 {
     BooksBl.UpdateBook(book);
 }