// method for updating a product
        public int Product_Update(Product prod)
        {
            using (var context = new HTPSContext())
            {
                context.Entry(prod).State = System.Data.Entity.EntityState.Modified;

                return(context.SaveChanges());
            }
        }
Esempio n. 2
0
 public int Customer_Add(Customer newcustomer)
 {
     using (var context = new HTPSContext())
     {
         context.Customers.Add(newcustomer);
         context.SaveChanges();
         return(newcustomer.CustomerID);
     }
 }
        public int Product_Delete(Product prod)
        {
            using (var context = new HTPSContext())
            {
                prod.Discontinued         = true;
                prod.DiscontinuedDate     = DateTime.Today;
                context.Entry(prod).State = System.Data.Entity.EntityState.Modified;

                return(context.SaveChanges());
            }
        }
        // method for adding a product
        public int Product_Add(Product prod)
        {
            using (var context = new HTPSContext())
            {
                context.Products.Add(prod);

                context.SaveChanges();

                return(prod.ProductID);
            }
        }