Exemplo n.º 1
0
        public async Task <ActionResult <Hotel.Data.Entities.Hotel> > PostHotel(Hotel.Data.Entities.Hotel hotel)
        {
            _context.Hotels.Add(hotel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetHotel", new { id = hotel.Id }, hotel));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PutHotel(int id, Hotel.Data.Entities.Hotel hotel)
        {
            if (id != hotel.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }