public IHttpActionResult PostClient(Client client) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Clients.Add(client); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = client.ClientId }, client); }
public IHttpActionResult PutClient(int id, Client client) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != client.ClientId) { return BadRequest(); } db.Entry(client).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ClientExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }