// PUT api/ManageSurvey/5 public IHttpActionResult PutSurvey(int id, Survey survey) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != survey.SurveyId) { return BadRequest(); } db.Entry(survey).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SurveyExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostSurvey(Survey survey) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Surveys.Add(survey); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = survey.SurveyId }, survey); }