public IHttpActionResult PutLetter(int id, Letter letter) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != letter.Id) { return BadRequest(); } db.Entry(letter).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LetterExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostLetter(Letter letter) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Letters.Add(letter); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = letter.Id }, letter); }