public async Task<IHttpActionResult> PutSurveyQuestion(int id, SurveyQuestion surveyQuestion) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != surveyQuestion.SurveyQuestionId) { return BadRequest(); } db.Entry(surveyQuestion).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SurveyQuestionExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostSurveyQuestion(SurveyQuestion surveyQuestion) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Questions.Add(surveyQuestion); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = surveyQuestion.SurveyQuestionId }, surveyQuestion); }