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

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

            using (var ctx = new ProductsContext())
            {
                products = ctx.Products.ToList();
            }
            return(products);
        }
Beispiel #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();
            }
        }