public IHttpActionResult PostDeceased(Deceased deceased) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Deceased.Add(deceased); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = deceased.Id }, deceased); }
public IHttpActionResult PutDeceased(int id, Deceased deceased) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != deceased.Id) { return BadRequest(); } db.Entry(deceased).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DeceasedExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }