public IHttpActionResult Postparticipants(participants participants) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.participants.Add(participants); try { db.SaveChanges(); } catch (DbUpdateException e) { if (participantsExists(participants.username)) { return Conflict(); } else { throw e; } } return CreatedAtRoute("DefaultApi", new { id = participants.username }, participants); }
public IHttpActionResult Putparticipants(string id, participants participants) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != participants.username) { return BadRequest(); } db.Entry(participants).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!participantsExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }