public async Task<IHttpActionResult> PutClient(int id, Client client) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != client.Id) { return BadRequest(); } _context.Entry(client).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClientExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostClient(Client client) { if (!ModelState.IsValid) { return BadRequest(ModelState); } _context.Clients.Add(client); await _context.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = client.Id }, client); }