예제 #1
0
        public static void AddNewMember(Member m)
        {
            var context = new CommerceDbContext();

            context.Members.Add(m);
            context.SaveChanges();
        }
예제 #2
0
        public static void DeleteProduct(int id)
        {
            var     context = new CommerceDbContext();
            Product p       = context.Products.Find(id);

            context.Products.Remove(p);
            context.SaveChanges();
        }
예제 #3
0
        public static void Update(Product p)
        {
            var context = new CommerceDbContext();

            // tells EF this product has only been modified
            context.Entry(p).State = System.Data.Entity.EntityState.Modified;
            // send update querty to the database
            context.SaveChanges();
        }
예제 #4
0
        /// <summary>
        /// Add product to the database
        /// </summary>
        /// <param name="p">Product to be added</param>
        public static void AddProduct(Product p)
        {
            //Create instance of DBContext class
            var context = new CommerceDbContext();

            //Prepare insert statement
            context.Products.Add(p);

            //Execute pending insert
            context.SaveChanges();
        }