public static void AddBook(Book book) { using (var context = new DbContext()) { context.Books.Add(book); context.SaveChanges(); } BookAddedOrDeleted?.Invoke(EventArgs.Empty); }
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); }