public async Task <IActionResult> PutBooking([FromRoute] int id, [FromBody] Booking booking)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != booking.Id)
            {
                return(BadRequest());
            }

            _context.Entry(booking).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BookingExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #2
0
        public async Task <IActionResult> PostAmenity([FromBody] Amenity amenity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Amenity.Add(amenity);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAmenity", new { id = amenity.Id }, amenity));
        }
        public async Task <IActionResult> PostRoom([FromBody] Room room)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (!RoomExistWithRoomNumber(room.RoomNumber))
            {
                _context.Room.Add(room);
                await _context.SaveChangesAsync();
            }



            return(CreatedAtAction("GetRoom", new { id = room.Id }, room));
        }