Exemple #1
0
 public void addProduct(product p)
 {
     using (var ctx = new ProductsContext())
     {
         ctx.Products.Add(p);
         ctx.SaveChanges();
     }
 }
Exemple #2
0
        public product getProduct(long ID)
        {
            product Product;

            using (var ctx = new ProductsContext())
            {
                Product = ctx.Products.FirstOrDefault(p => p.productID == ID);
            }
            return(Product);
        }
Exemple #3
0
        public System.Collections.IEnumerable getProducts()
        {
            List <product> products = new List <product>();

            using (var ctx = new ProductsContext())
            {
                products = ctx.Products.ToList();
            }
            return(products);
        }
Exemple #4
0
        public void updateProduct(product newProduct)
        {
            product Product;

            using (var ctx = new ProductsContext())
            {
                Product = ctx.Products.FirstOrDefault(p => p.productID == newProduct.productID);
                Product.DeepCopy(newProduct);
                ctx.SaveChanges();
            }
        }