Exemplo n.º 1
0
 public void AddBook(Book newBook)
 {
     try
     {
         BookDataContext bookData = new BookDataContext();
         bookData.Books.InsertOnSubmit(newBook);
         bookData.SubmitChanges();
     }
     catch (Exception ex)
     {
         throw new Exception("Error:" + ex.Message);
     }
 }
Exemplo n.º 2
0
 public void DeleteBook(Book deletebook)
 {
     try
     {
         BookDataContext bookData = new BookDataContext();
         Book            book     = bookData.Books.SingleOrDefault(b => b.BookID.Equals(deletebook.BookID));
         bookData.Books.DeleteOnSubmit(book);
         bookData.SubmitChanges();
     }
     catch (Exception ex)
     {
         throw new Exception("Error: " + ex.Message);
     }
 }
Exemplo n.º 3
0
 public void Update(Book updateBook)
 {
     try
     {
         BookDataContext bookData = new BookDataContext();
         Book            book     = bookData.Books.SingleOrDefault(b => b.BookID.Equals(updateBook.BookID));
         book.BookPrice = updateBook.BookPrice;
         book.BookTitle = updateBook.BookTitle;
         bookData.SubmitChanges();
     }
     catch (Exception ex)
     {
         throw new Exception("Error " + ex.Message);
     }
 }