public async Task<IHttpActionResult> PostSpindleBeltPara(SpindleBeltPara spindleBeltPara) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.SpindleBeltParas.Add(spindleBeltPara); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (SpindleBeltParaExists(spindleBeltPara.TypeID)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = spindleBeltPara.TypeID }, spindleBeltPara); }
public async Task<IHttpActionResult> PutSpindleBeltPara(string id, SpindleBeltPara spindleBeltPara) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != spindleBeltPara.TypeID) { return BadRequest(); } db.Entry(spindleBeltPara).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SpindleBeltParaExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }