public IHttpActionResult PutEquipment(int id, Equipment equipment) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != equipment.ID) { return BadRequest(); } db.Entry(equipment).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EquipmentExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostEquipment(Equipment equipment) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Equipments.Add(equipment); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = equipment.ID }, equipment); }