public async Task<IHttpActionResult> PutSessions(Guid id, Sessions sessions) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != sessions.id) { return BadRequest(); } db.Entry(sessions).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SessionsExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostSessions(Sessions sessions) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Sessions.Add(sessions); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = sessions.id }, sessions); }