Exemplo n.º 1
0
 public void UpdateCategory(Category category)
 {
     using (var context = new NMContext())
     {
         context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public void SaveCategory(Category category)
 {
     using (var context = new NMContext())
     {
         context.Categories.Add(category);
         context.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public void UpdateProduct(Product product)
 {
     using (var context = new NMContext())
     {
         context.Entry(product).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemplo n.º 4
0
 public void DeleteCategory(int ID)
 {
     using (var context = new NMContext())
     {
         //context.Entry(category).State = System.Data.Entity.EntityState.Deleted;
         var category = context.Categories.Find(ID);
         context.Categories.Remove(category);
         context.SaveChanges();
     }
 }
Exemplo n.º 5
0
        public void SaveProduct(Product product)
        {
            using (var context = new NMContext())
            {
                context.Entry(product.Category).State = System.Data.Entity.EntityState.Unchanged;

                context.Products.Add(product);
                context.SaveChanges();
            }
        }
Exemplo n.º 6
0
 public void DeleteProduct(int ID)
 {
     using (var context = new NMContext())
     {
         //context.Entry(category).State = System.Data.Entity.EntityState.Deleted;
         var product = context.Products.Find(ID);
         context.Products.Remove(product);
         context.SaveChanges();
     }
 }
Exemplo n.º 7
0
 public virtual void Insert(TEntity entity, bool SaveChanges = true)
 {
     dbSet.Add(entity);
     if (SaveChanges == true)
     {
         context.SaveChanges();
     }
 }
Exemplo n.º 8
0
 public void Save()
 {
     _context.SaveChanges();
 }