public IHttpActionResult PutSpecialModel(int id, SpecialModel specialModel) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != specialModel.id) { return BadRequest(); } db.Entry(specialModel).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SpecialModelExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostSpecialModel(SpecialModel specialModel) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.SpecialModels.Add(specialModel); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = specialModel.id }, specialModel); }