public bool delete(Product product) { using (hackEntities mybook = new hackEntities()) { try { int bookid = Convert.ToInt32(product.bookID); bookEntity be = mybook.bookEntities.Single(p => p.bookID == bookid); mybook.bookEntities.Remove(be); mybook.SaveChanges(); return(true); } catch { return(false); } }; }
public bool edit(Product product) { using (hackEntities mybook = new hackEntities()) { try { int bookid = Convert.ToInt32(product.bookID); bookEntity be = mybook.bookEntities.Single(p => p.bookID == bookid); be.title = product.title; be.author = product.author; be.price = product.price; be.quantity = product.quantity; mybook.SaveChanges(); return(true); } catch { return(false); } }; }
public bool create(Product product) { using (hackEntities mybook = new hackEntities()) { try { bookEntity be = new bookEntity(); be.title = product.title; be.author = product.author; be.price = product.price; be.quantity = product.quantity; mybook.bookEntities.Add(be); mybook.SaveChanges(); return(true); } catch { return(false); } }; }