// PUT api/Narratives/5 public IHttpActionResult PutNarrative(int id, Narrative narrative) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != narrative.ID) { return BadRequest(); } db.Entry(narrative).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!NarrativeExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostNarrative(Narrative narrative) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Narratives.Add(narrative); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = narrative.ID }, narrative); }