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 UpdateProduct(Product product)
 {
     using (var context = new NMContext())
     {
         context.Entry(product).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemplo n.º 3
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.º 4
0
        public virtual bool DeleteAll(List <TEntity> entities, bool SaveChanges = true)
        {
            foreach (var entityToDelete in entities)
            {
                if (context.Entry(entityToDelete).State == EntityState.Detached)
                {
                    dbSet.Attach(entityToDelete);
                }

                else
                {
                    dbSet.Remove(entityToDelete);
                }
            }
            if (SaveChanges == true)
            {
                return(context.SaveChanges() > Convert.ToInt32(Enums.AppConsts.NONE));
            }
            return(false);
        }