public IHttpActionResult PutLogAnswer(int id, LogAnswer logAnswer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != logAnswer.LogAnswerId) { return(BadRequest()); } db.Entry(logAnswer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LogAnswerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetLogAnswer(int id) { LogAnswer logAnswer = db.LogAnswer.Find(id); if (logAnswer == null) { return(NotFound()); } return(Ok(logAnswer)); }
public IHttpActionResult PostLogAnswer(LogAnswer logAnswer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.LogAnswer.Add(logAnswer); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = logAnswer.LogAnswerId }, logAnswer)); }
public IHttpActionResult DeleteLogAnswer(int id) { LogAnswer logAnswer = db.LogAnswer.Find(id); if (logAnswer == null) { return(NotFound()); } db.LogAnswer.Remove(logAnswer); db.SaveChanges(); return(Ok(logAnswer)); }