Exemple #1
0
        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());
        }
Exemple #2
0
 public void Put(int id, [FromBody] Animal animal)
 {
     animal.AnimalId         = id;
     _db.Entry(animal).State = EntityState.Modified;
     _db.SaveChanges();
 }
Exemple #3
0
 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();
 }