public async Task<IHttpActionResult> Postuser(user user) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.user.Add(user); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = user.userId }, user); }
public async Task CreateUser(user u) { db.user.Add(u); await db.SaveChangesAsync(); }
public async Task<IHttpActionResult> Putuser(int id, user user) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != user.userId) { return BadRequest(); } db.Entry(user).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!userExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }