public Customer Add(Customer item) { if (item == null) { throw new ArgumentNullException("item"); } // TO DO : Code to save record into database db.Customers.Add(item); db.SaveChanges(); return(item); }
public Product Add(Product item) { if (item == null) { throw new ArgumentNullException("item"); } // TO DO : Code to save record into database db.Products.Add(item); db.SaveChanges(); return(item); }
public int AddProduct(Product product) { using (HAO_Entities db = new HAO_Entities()) { db.Products.Add(product); return(db.SaveChanges()); } }
public int ModifyCustomer(Customer customer) { using (HAO_Entities db = new HAO_Entities()) { db.Customers.Attach(customer); db.Entry <Customer>(customer).State = EntityState.Modified; return(db.SaveChanges()); } }
// add customer public int AddCustomer(Customer customer) { using (HAO_Entities db = new HAO_Entities()) { db.Customers.Add(customer); return(db.SaveChanges()); } }
public int ModidyProduct(Product product) { using (HAO_Entities db = new HAO_Entities()) { db.Products.Attach(product); db.Entry <Product>(product).State = EntityState.Modified; return(db.SaveChanges()); } }
public int DeleteCustomer(int customerId) { using (HAO_Entities db = new HAO_Entities()) { Customer c = new Customer() { Id = customerId }; db.Customers.Attach(c); db.Customers.Remove(c); return(db.SaveChanges()); } }
public int DeleteProduct(int productId) { using (HAO_Entities db = new HAO_Entities()) { Product p = new Product() { Id = productId }; db.Products.Attach(p); db.Products.Remove(p); return(db.SaveChanges()); } }