public int AddProduct(Product product) { using (HAOEntities db = new HAOEntities()) { db.Products.Add(product); return(db.SaveChanges()); } }
public int ModidyProduct(Product product) { using (HAOEntities db = new HAOEntities()) { db.Products.Attach(product); db.Entry <Product>(product).State = EntityState.Modified; return(db.SaveChanges()); } }
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()); } }