Example #1
0
 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);
         }
     };
 }
Example #2
0
 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);
         }
     };
 }
Example #3
0
 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);
         }
     };
 }