Beispiel #1
0
 public List <Product> findAll()
 {
     using (hackEntities mybook = new hackEntities()) {
         return(mybook.bookEntities.Select(be => new Product {
             bookID = be.bookID,
             title = be.title,
             author = be.author,
             price = be.price.Value,
             quantity = be.quantity.Value
         }).ToList());
     };
 }
Beispiel #2
0
 public Product find(string book_ID)
 {
     using (hackEntities mybook = new hackEntities())
     {
         int bookid = Convert.ToInt32(book_ID);
         return(mybook.bookEntities.Where(be => be.bookID == bookid).Select(be => new Product
         {
             bookID = be.bookID,
             title = be.title,
             author = be.author,
             price = be.price.Value,
             quantity = be.quantity.Value
                        //creationDate = be.creationDate
         }).First());
     };
 }
Beispiel #3
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);
         }
     };
 }
Beispiel #4
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);
         }
     };
 }
Beispiel #5
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);
         }
     };
 }