コード例 #1
0
 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();
 }
コード例 #2
0
 public virtual async Task <TEntity> Delete(TEntity entityToDelete)
 {
     if (_context.Entry(entityToDelete).State == EntityState.Detached)
     {
         dbSet.Attach(entityToDelete);
     }
     dbSet.Remove(entityToDelete);
     return(entityToDelete);
 }
コード例 #3
0
        public void Delete(TKey id)
        {
            TEntity entityToDelete = DbSet.Find(id);

            if (_context.Entry(entityToDelete).State == EntityState.Detached)
            {
                DbSet.Attach(entityToDelete);
            }
            DbSet.Remove(entityToDelete);
        }
コード例 #4
0
        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());
        }
コード例 #5
0
        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());
        }