예제 #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
                {
                    //_context.Update(hotel);
                    //await _context.SaveChangesAsync();
                    await _context.EditHotel(hotel);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HotelExists(hotel.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(hotel));
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,StreetAddress,City,State,Phone")] Hotel hotel)
        {
            if (id != hotel.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _hotels.EditHotel(id, hotel);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HotelExists(hotel.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(hotel));
        }
예제 #3
0
        // PUT api/Hotel/Put/5
        public IHttpActionResult Put(int id, HotelViewModel hvmodel)
        {
            var h = _hotelManager.EditHotel(id, hvmodel);

            return(Ok(h));
        }
예제 #4
0
 /// <summary>
 /// Action To Get Hotel Details To Upadte
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ActionResult EditHotel(int id)
 {
     return(View(hotelManager.EditHotel(id)));
 }