public async Task<IHttpActionResult> PutroomContent(int roomId,int accessoryId, roomContent roomContent) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (roomId != roomContent.roomId || accessoryId != roomContent.accessoryId) { return BadRequest(); } db.Entry(roomContent).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!roomContentExists(roomId, accessoryId)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostroomContent(roomContent roomContent) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.roomContent.Add(roomContent); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (roomContentExists(roomContent.roomId, roomContent.accessoryId)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = roomContent.roomId }, roomContent); }