コード例 #1
0
 public void UpdateProduct(Product Product)
 {
     using (var context = new GeekHubContext())
     {
         context.Entry(Product).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
コード例 #2
0
 public void UpdateCategory(Category category)
 {
     using (var context = new GeekHubContext())
     {
         context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
コード例 #3
0
 public void SaveCategory(Category category)
 {
     using (var context = new GeekHubContext())
     {
         context.Categories.Add(category);
         context.SaveChanges();      //to enter in the database
     }
 }
コード例 #4
0
 public void DeleteProduct(int ID)
 {
     using (var context = new GeekHubContext())
     {
         var Product = GetProduct(ID);
         context.Entry(Product).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
     }
 }
コード例 #5
0
 public void SaveProduct(Product product)
 {
     using (var context = new GeekHubContext())
     {
         context.Entry(product.ProductCategory).State = System.Data.Entity.EntityState.Unchanged;
         context.Products.Add(product);
         context.SaveChanges();      //to enter in the database
     }
 }
コード例 #6
0
 public void DeleteCategory(int ID)
 {
     using (var context = new GeekHubContext())
     {
         var category = GetCategory(ID);
         context.Entry(category).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
     }
 }