public IHttpActionResult PutOption(int id, Option option) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != option.OptionId) { return BadRequest(); } db.Entry(option).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!OptionExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostOption(Option option) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Options.Add(option); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = option.OptionId }, option); }