public IHttpActionResult PutUsers(int id, Users users) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != users.Id) { return BadRequest(); } db.Entry(users).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UsersExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostUsers(Users users) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Users.Add(users); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = users.Id }, users); }