public async Task <IActionResult> Postrooms_amenities([FromBody] rooms_amenities rooms_amenities) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.rooms_amenities.Add(rooms_amenities); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (rooms_amenitiesExists(rooms_amenities.room_id)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("Getrooms_amenities", new { id = rooms_amenities.room_id }, rooms_amenities)); }
public async Task <IActionResult> Putrooms_amenities([FromRoute] int id, [FromBody] rooms_amenities rooms_amenities) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != rooms_amenities.room_id) { return(BadRequest()); } _context.Entry(rooms_amenities).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!rooms_amenitiesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }