Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int?id, [Bind("ID, Name, Address, Phone")] HotelLocation location)
        {
            if (id == null || id != location.ID)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(View(location));
            }

            try
            {
                _context.Add(location);
                await _context.SaveChangesAsync();
            } catch (DbUpdateConcurrencyException)
            {
                if (_context.HotelLocations.FirstOrDefault(hl => hl.ID == id) == null)
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }

            HotelLocation location = await _context.HotelLocations.Where(hl => hl.ID == id).FirstOrDefaultAsync();

            if (location == null)
            {
                return(NotFound());
            }

            return(View(location));
        }