public async Task <IActionResult> Put(int id, Animal animal) { if (id != animal.AnimalId) { return(BadRequest()); } _db.Entry(animal).State = EntityState.Modified; try { await _db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AnimalExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Put(int id, [FromBody] Animal animal) { animal.AnimalId = id; _db.Entry(animal).State = EntityState.Modified; _db.SaveChanges(); }
public void Put(int id, [FromBody] Animal animal) //we will need to specify the changes we want to make in the body of the API call. { animal.AnimalId = id; _db.Entry(animal).State = EntityState.Modified; _db.SaveChanges(); }
public void Put(int id, [FromBody] Animal animal) { animal.AnimalId = id; _db.Entry(animal).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _db.SaveChanges(); }