コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public int AddProduct(Product product)
 {
     using (HAO_Entities db = new HAO_Entities())
     {
         db.Products.Add(product);
         return(db.SaveChanges());
     }
 }
コード例 #4
0
 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());
     }
 }
コード例 #5
0
        // add customer
        public int AddCustomer(Customer customer)
        {
            using (HAO_Entities db = new HAO_Entities())
            {
                db.Customers.Add(customer);

                return(db.SaveChanges());
            }
        }
コード例 #6
0
 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());
     }
 }
コード例 #7
0
        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());
            }
        }
コード例 #8
0
        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());
            }
        }