public virtual void Delete(TEntity entityToDelete) { if (Context.Entry(entityToDelete).State == EntityState.Detached) { DbSet.Attach(entityToDelete); } DbSet.Remove(entityToDelete); }
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; }
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;; }
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; }
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; }
public int Update(T t) { var entry = Context.Entry(t); DbSet.Attach(t); entry.State = System.Data.EntityState.Modified; return(Context.SaveChanges()); }