예제 #1
0
 public virtual void Delete(TEntity entityToDelete)
 {
     if (Context.Entry(entityToDelete).State == EntityState.Detached)
     {
         DbSet.Attach(entityToDelete);
     }
     DbSet.Remove(entityToDelete);
 }
예제 #2
0
        public void UpdateGood(Good good)
        {
            var existingGood = _context.Goods.FirstOrDefault(gd => gd.Id == good.Id);

            if (existingGood == null)
            {
                return;
            }
            _context.Entry(existingGood).CurrentValues.SetValues(good);
            _context.Entry(existingGood).State = EntityState.Modified;
        }
예제 #3
0
        public void UpdateUser(User user)
        {
            var existingUser = _context.Users.FirstOrDefault(usr => usr.Id == user.Id);

            if (existingUser == null)
            {
                return;
            }
            _context.Entry(existingUser).CurrentValues.SetValues(user);
            _context.Entry(existingUser).State = EntityState.Modified;;
        }
예제 #4
0
        public void UpdateCell(Cell cell)
        {
            var existingCell = _context.Cells.SingleOrDefault(cl => cl.Id == cell.Id);

            if (existingCell == null)
            {
                return;
            }

            _context.Entry(existingCell).CurrentValues.SetValues(cell);
            _context.Entry(existingCell).State = EntityState.Modified;
        }
예제 #5
0
        public void UpdateWarehouse(Warehouse warehouse)
        {
            var currentWarehouse = _context.Warehouses.SingleOrDefault(whs => whs.Id == warehouse.Id);

            if (currentWarehouse == null)
            {
                return;
            }

            _context.Entry(currentWarehouse).CurrentValues.SetValues(warehouse);
            _context.Entry(currentWarehouse).State = EntityState.Modified;
        }
예제 #6
0
        public int Update(T t)
        {
            var entry = Context.Entry(t);

            DbSet.Attach(t);

            entry.State = System.Data.EntityState.Modified;

            return(Context.SaveChanges());
        }