예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Address,Phone")] Hotel hotel)
        {
            if (id != hotel.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _hotel.UpdateHotel(hotel);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HotelExists(hotel.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(hotel));
        }
        public async Task <IActionResult> PutHotel(int id, Hotel hotel)
        {
            if (id != hotel.Id)
            {
                return(BadRequest());
            }
            var updatedHotel = await _hotel.UpdateHotel(id, hotel);

            return(Ok(updatedHotel));
        }
예제 #3
0
        public IActionResult Edit(int id, [Bind("ID,Name,Address,Phone")] Hotel hotel)
        {
            if (id != hotel.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                _context.UpdateHotel(hotel);
                return(RedirectToAction(nameof(Index)));
            }
            return(View(hotel));
        }