public IHttpActionResult PutLogEntry(int id, LogEntry logEntry) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != logEntry.ID) { return BadRequest(); } db.Entry(logEntry).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LogEntryExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostLogEntry(LogEntry logEntry) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.LogEntries.Add(logEntry); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = logEntry.ID }, logEntry); }