public async Task <IActionResult> PutUser(int id, User user)
        {
            if (id != user.ID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutHotel(int id, Hotel hotel)
        {
            if (id != hotel.HotelID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #3
0
        public async Task <IActionResult> PutBooking(int id, PostBooking booking)
        {
            Booking b = new Booking()
            {
                BookedRoomID = booking.RoomId,
                UserID       = booking.UserID,
                BookingID    = id,
                StartDate    = booking.StartDate,
                EndDate      = booking.EndDate,
                Adress       = booking.Adress,
                PhoneNumber  = booking.PhoneNumber
            };

            if (id != b.BookingID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }