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); } }
public bool UpdatePublisher(int id, string pub) { using (LinqLibraryDataContext dataContext = new LinqLibraryDataContext()) { if (dataContext.GetBook(id) == null) { return(false); } else { dataContext.UpdatePublisher(id, pub); return(true); } } }
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); } }