public async Task<IHttpActionResult> PutZombie(int id, Zombie zombie) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != zombie.Id) { return BadRequest(); } db.Entry(zombie).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ZombieExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostZombie(Zombie zombie) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Zombies.Add(zombie); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = zombie.Id }, zombie); }