public async Task<IHttpActionResult> PutRooms(int id, Rooms rooms) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != rooms.id) { return BadRequest(); } db.Entry(rooms).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoomsExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostRooms(Rooms rooms) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Rooms.Add(rooms); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = rooms.id }, rooms); }