示例#1
0
 public void UpdateCategory(Category category)
 {
     using (var context = new MvcComContext())
     {
         context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
示例#2
0
 public void UpdateProduct(Product product)
 {
     using (var context = new MvcComContext())
     {
         context.Entry(product).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
示例#3
0
        public void SaveCategory(Category category)
        {
            using (var context = new MvcComContext())
            {
                context.Categories.Add(category);

                context.SaveChanges();
            }
        }
示例#4
0
        public void SaveProduct(Product product)
        {
            using (var context = new MvcComContext())
            {
                context.Products.Add(product);

                context.SaveChanges();
            }
        }
示例#5
0
 public void DeleteCategory(int ID)
 {
     using (var context = new MvcComContext())
     {
         var category = context.Categories.Find(ID);
         //context.Entry(category).State = System.Data.Entity.EntityState.Deleted;
         //both will work
         context.Categories.Remove(category);
         context.SaveChanges();
     }
 }