Beispiel #1
0
 public bool UpdateBook(int ID, string title, string author, string publisher, int year)
 {
     using (LinqLibraryDataContext dataContext = new LinqLibraryDataContext())
     {
         if (dataContext.GetBook(ID) != null)
         {
             dataContext.UpdateTitle(ID, title);
             dataContext.UpdateAuthor(ID, author);
             dataContext.UpdatePublisher(ID, publisher);
             dataContext.UpdateYear(ID, year);
             return(true);
         }
         return(false);
     }
 }
Beispiel #2
0
 public bool UpdateTitle(int id, string tit)
 {
     using (LinqLibraryDataContext dataContext = new LinqLibraryDataContext())
     {
         if (dataContext.GetBook(id) == null)
         {
             return(false);
         }
         else
         {
             dataContext.UpdateTitle(id, tit);
             return(true);
         }
     }
 }
Beispiel #3
0
 public void TestUpdatingBooks()
 {
     using (LinqLibraryDataContext rep = new LinqLibraryDataContext(m_ConnectionString))
     {
         rep.AddBook("just a book", "with some author", "publisher", 2002);
         Book hello = rep.GetBook("just a book");
         rep.UpdateAuthor(hello.book_ID, "not a book");
         rep.UpdatePublisher(hello.book_ID, "not a publisher");
         rep.UpdateTitle(hello.book_ID, "not an author");
         Book bye = rep.GetBook(hello.book_ID);
         Assert.AreEqual("not a book", bye.author);
         Assert.AreEqual("not a publisher", bye.publisher);
         Assert.AreEqual("not an author", bye.title);
     }
 }