//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Manage books //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public int addBook(string title, string author, string publisher) { int catNumber = 0; Book book = new Book { Title = title, Author = author, Publisher = publisher }; db.Books.InsertOnSubmit(book); db.SubmitChanges(); //submit the action to customer table catNumber = book.CatalogueNumber; /*var newBook = from b in db.Books where b.Title == title select b.CatalogueNumber; foreach (var b in newBook) { catNumber = Convert.ToInt32(b); }*/ return catNumber; }
public Book findBookByCatNum(int catnum) { Book rb = new Book(); bool found = false; var books = from b in db.Books where b.CatalogueNumber == catnum select new { b.CatalogueNumber, b.Author, b.Title, b.Publisher }; foreach (var b in books) { rb.CatalogueNumber = b.CatalogueNumber; rb.Author = b.Author; rb.Title = b.Title; rb.Publisher = b.Publisher; found = true; } if (!found) return null; return rb; }
partial void UpdateBook(Book instance);
partial void DeleteBook(Book instance);
partial void InsertBook(Book instance);