Esempio n. 1
0
        public static void AddNewMember(Member m)
        {
            var context = new CommerceDbContext();

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

            context.Products.Remove(p);
            context.SaveChanges();
        }
Esempio n. 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();
        }
Esempio n. 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();
        }