public async Task<IHttpActionResult> PostGearCoup(GearCoup gearCoup) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.GearCouplings.Add(gearCoup); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (GearCoupExists(gearCoup.TypeID)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = gearCoup.TypeID }, gearCoup); }
public async Task<IHttpActionResult> PutGearCoup(string id, GearCoup gearCoup) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != gearCoup.TypeID) { return BadRequest(); } db.Entry(gearCoup).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GearCoupExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task <IActionResult> PostGearCoup([FromBody] GearCoup gearCoup) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.GearCouplings.Add(gearCoup); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (GearCoupExists(gearCoup.TypeID)) { return(StatusCode((int)HttpStatusCode.Conflict)); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = gearCoup.TypeID }, gearCoup)); }
public async Task <IActionResult> PutGearCoup(string id, [FromBody] GearCoup gearCoup) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != gearCoup.TypeID) { return(BadRequest()); } db.Entry(gearCoup).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GearCoupExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode((int)HttpStatusCode.NoContent)); }
public async Task <IActionResult> GetGearCoup(string id) { GearCoup gearCoup = await db.GearCouplings.FindAsync(id); if (gearCoup == null) { return(NotFound()); } return(Ok(gearCoup)); }
public async Task <IActionResult> DeleteGearCoup(string id) { GearCoup gearCoup = await db.GearCouplings.FindAsync(id); if (gearCoup == null) { return(NotFound()); } db.GearCouplings.Remove(gearCoup); await db.SaveChangesAsync(); return(Ok(gearCoup)); }