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