public async Task<IHttpActionResult> PutConversation(int id, Conversation conversation) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != conversation.Id) { return BadRequest(); } db.Entry(conversation).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ConversationExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostConversation(Conversation conversation) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Conversations.Add(conversation); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = conversation.Id }, conversation); }