public IHttpActionResult PostLog(Log log) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Logs.Add(log); try { db.SaveChanges(); } catch (DbUpdateException) { if (LogExists(log.Id)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = log.Id }, log); }
public IHttpActionResult PutLog(int id, Log log) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != log.Id) { return BadRequest(); } db.Entry(log).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LogExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }