public IHttpActionResult PutLiveChat(int id, LiveChat liveChat) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != liveChat.ID) { return BadRequest(); } db.Entry(liveChat).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LiveChatExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostLiveChat(LiveChat liveChat) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.LiveChats.Add(liveChat); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = liveChat.ID }, liveChat); }