コード例 #1
0
 public static void AddBook(Book book)
 {
     using (var context = new DbContext()) {
         context.Books.Add(book);
         context.SaveChanges();
     }
     BookAddedOrDeleted?.Invoke(EventArgs.Empty);
 }
コード例 #2
0
 public static void DeleteBook(string catalogueNumber)
 {
     using (var context = new DbContext()) {
         var book = context.Books.Find(catalogueNumber);
         if (book == null)
         {
             throw new NullReferenceException("Nie znaleziono ksiazki w bazie danych");
         }
         context.Books.Remove(book);
         context.SaveChanges();
     }
     BookAddedOrDeleted?.Invoke(EventArgs.Empty);
 }