public void deleteBook(int bookID) { var book = new Book(); book = context.Books.First(c => c.BookID == bookID); context.Books.DeleteObject(book); context.SaveChanges(); }
/// <summary> /// Create a new Book object. /// </summary> /// <param name="bookID">Initial value of the BookID property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="categoryID">Initial value of the CategoryID property.</param> /// <param name="author">Initial value of the Author property.</param> /// <param name="publisher">Initial value of the Publisher property.</param> /// <param name="edition">Initial value of the Edition property.</param> /// <param name="yearOfPublishion">Initial value of the YearOfPublishion property.</param> public static Book CreateBook(global::System.Int32 bookID, global::System.String title, global::System.Int32 categoryID, global::System.String author, global::System.String publisher, global::System.Int32 edition, global::System.DateTime yearOfPublishion) { Book book = new Book(); book.BookID = bookID; book.Title = title; book.CategoryID = categoryID; book.Author = author; book.Publisher = publisher; book.Edition = edition; book.YearOfPublishion = yearOfPublishion; return book; }
/// <summary> /// Deprecated Method for adding a new object to the Books EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToBooks(Book book) { base.AddObject("Books", book); }
private void AddNewBook() { var book = new Book(); book.Author = txtAuthor.Text; book.CategoryID = Convert.ToInt32(cboCatagoyName.SelectedValue.ToString()); book.Edition = Convert.ToInt32(txtEdition.Text); book.ISBN = txtISBN.Text; book.Publisher = txtPublisher.Text; book.Title = txtTitle.Text; book.YearOfPublishion = dtPickerYearofPublish.Value; foreach(BookCopy c in copies) { BookCopy newCopy = new BookCopy(); newCopy.BookID = c.BookID; newCopy.BookCopyID = c.BookCopyID; newCopy.Status = c.Status; newCopy.BookShelfNo = c.BookShelfNo; book.BookCopies.Add(newCopy); } context.Books.AddObject(book); context.SaveChanges(); // update latest no in Number var lastBookCopy = (from x in context.Books select x).OrderByDescending(x => x.BookID).Take(1); foreach(Book b in lastBookCopy) { bookid = b.BookID; } newform = false; }