예제 #1
0
        internal static void DeleteProduct(Product p)
        {
            var db = new TeamProjectFinalDB();

            db.Products.Remove(p);
            db.SaveChanges();
        }
예제 #2
0
        public static List <Product> GetAllProducts()
        {
            TeamProjectFinalDB db    = new TeamProjectFinalDB();
            List <Product>     prods = db.Products.ToList();

            return(prods);
        }
예제 #3
0
        /// <summary>
        /// returns a product with the given id
        /// if no product is found, null is returned.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static Product GetProductById(int id)
        {
            TeamProjectFinalDB db   = new TeamProjectFinalDB();
            Product            prod = db.Products.Find(id);

            return(prod);
        }
예제 #4
0
        internal static void AddProduct(Product p)
        {
            var db = new TeamProjectFinalDB();

            db.Products.Add(p);//
            db.SaveChanges();
        }
예제 #5
0
        public static void Subsribe(Subscriber s)
        {
            TeamProjectFinalDB db = new TeamProjectFinalDB();

            db.Subscribers.Add(s);
            db.SaveChanges();
        }
예제 #6
0
        public static void UpdateProduct(Product p)
        {
            TeamProjectFinalDB db = new TeamProjectFinalDB();

            //notifies context that product has been changed
            db.Entry(p).State = EntityState.Modified;

            //sends update query to database.
            db.SaveChanges();
        }
예제 #7
0
        public static void DeleteProduct()
        {
            TeamProjectFinalDB db = new TeamProjectFinalDB();

            db.Database.ExecuteSqlCommand("DELE Product");
        }