public IHttpActionResult PutVictim(int id, Victim victim) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != victim.VictimId) { return BadRequest(); } db.Entry(victim).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!VictimExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostVictim(Victim victim) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Victims.Add(victim); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = victim.VictimId }, victim); }