public async Task <IActionResult> PostStraightBevelGear([FromBody] StraightBevelGear straightBevelGear) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.StraightBevelGears.Add(straightBevelGear); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (StraightBevelGearExists(straightBevelGear.TypeID)) { return(StatusCode((int)HttpStatusCode.Conflict)); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = straightBevelGear.TypeID }, straightBevelGear)); }
public async Task <IActionResult> PutStraightBevelGear(string id, [FromBody] StraightBevelGear straightBevelGear) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != straightBevelGear.TypeID) { return(BadRequest()); } db.Entry(straightBevelGear).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StraightBevelGearExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode((int)HttpStatusCode.NoContent)); }
public async Task<IHttpActionResult> PostStraightBevelGear(StraightBevelGear straightBevelGear) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.StraightBevelGears.Add(straightBevelGear); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (StraightBevelGearExists(straightBevelGear.TypeID)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = straightBevelGear.TypeID }, straightBevelGear); }
public async Task<IHttpActionResult> PutStraightBevelGear(string id, StraightBevelGear straightBevelGear) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != straightBevelGear.TypeID) { return BadRequest(); } db.Entry(straightBevelGear).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StraightBevelGearExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task <IActionResult> GetStraightBevelGear(string id) { StraightBevelGear straightBevelGear = await db.StraightBevelGears.FindAsync(id); if (straightBevelGear == null) { return(NotFound()); } return(Ok(straightBevelGear)); }
public async Task <IActionResult> DeleteStraightBevelGear(string id) { StraightBevelGear straightBevelGear = await db.StraightBevelGears.FindAsync(id); if (straightBevelGear == null) { return(NotFound()); } db.StraightBevelGears.Remove(straightBevelGear); await db.SaveChangesAsync(); return(Ok(straightBevelGear)); }