public IHttpActionResult PutRobotPart(int id, RobotPart robotPart) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != robotPart.Id) { return BadRequest(); } db.Entry(robotPart).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RobotPartExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostRobotPart(RobotPart robotPart) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.RobotParts.Add(robotPart); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = robotPart.Id }, robotPart); }