public IHttpActionResult PostFeedback(Feedback feedback) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Feedbacks.Add(feedback); try { db.SaveChanges(); } catch (DbUpdateException) { if (FeedbackExists(feedback.AppID)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = feedback.AppID }, feedback); }
// PUT api/Feedback/5 public IHttpActionResult PutFeedback(int id, Feedback feedback) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != feedback.AppID) { return BadRequest(); } db.Entry(feedback).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!FeedbackExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }