public async Task<IHttpActionResult> PutUserData(int id, UserData userData) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != userData.Id) { return BadRequest(); } db.Entry(userData).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserDataExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostUserData(UserData userData) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.UserDatas.Add(userData); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = userData.Id }, userData); }