public async Task <IActionResult> Edit(RoomsEditModel model)
        {
            if (!IsUserAuthenticated())
            {
                return(Redirect("/Users/Login"));
            }

            if (!IsAdminAndActive())
            {
                return(Redirect("/Rooms/List"));
            }

            if (ModelState.IsValid)
            {
                Room room = new Room
                {
                    Id          = model.Id,
                    Number      = model.Number,
                    Capacity    = model.Capacity,
                    Price       = model.Price,
                    Description = model.Description,
                    Type        = model.Type,
                    IsFree      = model.IsFree
                };

                try
                {
                    _context.Update(room);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RoomExists(room.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(Redirect("/Rooms/List"));
            }
            return(View(model));
        }
        // GET: Rooms/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (!IsUserAuthenticated())
            {
                return(Redirect("/Users/Login"));
            }

            if (!IsAdminAndActive())
            {
                return(Redirect("/Rooms/List"));
            }

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

            Room room = await _context.Rooms.FindAsync(id);

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

            RoomsEditModel model = new RoomsEditModel
            {
                Id          = room.Id,
                Number      = room.Number,
                Capacity    = room.Capacity,
                Price       = room.Price,
                Description = room.Description,
                Type        = room.Type,
                IsFree      = room.IsFree
            };

            return(View(model));
        }