Exemplo n.º 1
0
 public void CreateProduct(Product product)
 {
     using (var db = new OskarEntities())
     {
         db.Products.Add(product);
         db.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public void UpdateProduct(Product product)
 {
     using (var db = new OskarEntities())
     {
         db.Products.Attach(product);
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public void DeleteProduct(int productId)
 {
     using (var db = new OskarEntities())
     {
         var product = new Product { ProductId = productId };
         db.Products.Attach(product);
         db.Products.Remove(product);
         db.SaveChanges();
     }
 }