public void UpdatePersona(int id, Persona persona) { //var per = _context.Personas.FirstOrDefault(p => p.Id == id); persona.ModifiedDate = DateTime.UtcNow; _context.Entry(persona).State = EntityState.Modified; Save(); }
public virtual async Task <TEntity> Delete(TEntity entityToDelete) { if (_context.Entry(entityToDelete).State == EntityState.Detached) { dbSet.Attach(entityToDelete); } dbSet.Remove(entityToDelete); return(entityToDelete); }
public void Delete(TKey id) { TEntity entityToDelete = DbSet.Find(id); if (_context.Entry(entityToDelete).State == EntityState.Detached) { DbSet.Attach(entityToDelete); } DbSet.Remove(entityToDelete); }
public async Task <IActionResult> PutCandidate(int idCandidate, [FromBody] Candidat candidat) { if (idCandidate != candidat.IdCandidat) { return(BadRequest()); } rhContext.Entry(candidat).State = EntityState.Modified; await rhContext.SaveChangesAsync(); return(NoContent()); }
public async Task <IActionResult> UpdateDirection(long idDirection, [FromBody] Direction direction) { //it is necessary to have the direction for know what we apply the update if (idDirection != direction.IdDirection) { return(BadRequest()); // this direction don't correspond a direction in the database } rhContext.Entry(direction).State = EntityState.Modified; await rhContext.SaveChangesAsync(); //Save the change of the same direction in the database return(NoContent()); }