public async Task<IHttpActionResult> PutAddresse(int id, Addresse addresse) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != addresse.Id) { return BadRequest(); } db.Entry(addresse).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AddresseExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostAddresse(Addresse addresse) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Addresses.Add(addresse); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = addresse.Id }, addresse); }