예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("AmenitiesID,RoomID")] RoomAmenities roomAmenities)
        {
            if (id != roomAmenities.AmenitiesID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(roomAmenities);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RoomAmenitiesExists(roomAmenities.AmenitiesID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AmenitiesID"] = new SelectList(_context.Amenities, "ID", "Name", roomAmenities.AmenitiesID);
            ViewData["RoomID"]      = new SelectList(_context.Room, "ID", "Name", roomAmenities.RoomID);
            return(View(roomAmenities));
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("HotelID,RoomNumber,RoomID,Rate,PetFriendly")] HotelRoom hotelRoom)
        {
            if (id != hotelRoom.HotelID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(hotelRoom);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HotelRoomExists(hotelRoom.HotelID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HotelID"] = new SelectList(_context.Hotel, "ID", "Name", hotelRoom.HotelID);
            ViewData["RoomID"]  = new SelectList(_context.Room, "ID", "Name");
            return(View(hotelRoom));
        }
예제 #3
0
 /// <summary>
 /// will update a selected amenity
 /// </summary>
 /// <param name="id">selected amenity</param>
 /// <param name="amenities">the amenity object</param>
 /// <returns>the task to controller</returns>
 public async Task UpdateAmenitie(int id, Amenities amenities)
 {
     try
     {
         _context.Update(amenities);
         await _context.SaveChangesAsync();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
예제 #4
0
 public async Task UpdateHotel(int id, [Bind("ID,Name,StreetAdress,City,State,Phone")] Hotel hotel)
 {
     try
     {
         _context.Update(hotel);
         await _context.SaveChangesAsync();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
예제 #5
0
 public async Task UpdateRoom(int id, [Bind("ID,Name,RoomLayout")] Room hotel)
 {
     _context.Update(hotel);
     await _context.SaveChangesAsync();
 }