// PUT api/Session/5 public async Task<IHttpActionResult> PutSessionModel(int id, SessionModel sessionmodel) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != sessionmodel.Id) { return BadRequest(); } _db.Entry(sessionmodel).State = EntityState.Modified; try { await _db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SessionModelExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostSessionModel(SessionModel sessionmodel) { if (!ModelState.IsValid) { return BadRequest(ModelState); } _db.Sessions.Add(sessionmodel); await _db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = sessionmodel.Id }, sessionmodel); }