Example #1
0
 public int AddProduct(Product product)
 {
     using (HAOEntities db = new HAOEntities())
     {
         db.Products.Add(product);
         return(db.SaveChanges());
     }
 }
Example #2
0
 public int ModidyProduct(Product product)
 {
     using (HAOEntities db = new HAOEntities())
     {
         db.Products.Attach(product);
         db.Entry <Product>(product).State = EntityState.Modified;
         return(db.SaveChanges());
     }
 }
Example #3
0
        public int DeleteProduct(int productId)
        {
            using (HAOEntities db = new HAOEntities())
            {
                Product p = new Product()
                {
                    Id = productId
                };

                db.Products.Attach(p);
                db.Products.Remove(p);

                return(db.SaveChanges());
            }
        }