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