public async Task <IHttpActionResult> Putordre(int id, ordre ordre) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != ordre.ordreID) { return(BadRequest()); } db.Entry(ordre).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ordreExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> Getordre(int id) { ordre ordre = await db.ordre.FindAsync(id); if (ordre == null) { return(NotFound()); } return(Ok(ordre)); }
public async Task <IHttpActionResult> Postordre(ordre ordre) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ordre.Add(ordre); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = ordre.ordreID }, ordre)); }
public async Task <IHttpActionResult> Deleteordre(int id) { ordre ordre = await db.ordre.FindAsync(id); if (ordre == null) { return(NotFound()); } db.ordre.Remove(ordre); await db.SaveChangesAsync(); return(Ok(ordre)); }