public IHttpActionResult PutHostType(int id, HostType hostType) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != hostType.ID) { return BadRequest(); } db.Entry(hostType).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!HostTypeExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostHostType(HostType hostType) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.HostTypes.Add(hostType); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = hostType.ID }, hostType); }