예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("TVSInRoomsId,TVSId,RoomsId")] TVSInRooms tVSInRooms)
        {
            if (id != tVSInRooms.TVSInRoomsId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tVSInRooms);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TVSInRoomsExists(tVSInRooms.TVSInRoomsId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RoomsId"] = new SelectList(_context.Rooms, "RoomsId", "RoomName", tVSInRooms.RoomsId);
            ViewData["TVSId"]   = new SelectList(_context.TVS, "TVSId", "Brand", tVSInRooms.TVSId);
            return(View(tVSInRooms));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("TVSInRoomsId,TVSId,RoomsId")] TVSInRooms tVSInRooms)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tVSInRooms);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RoomsId"] = new SelectList(_context.Rooms, "RoomsId", "RoomName", tVSInRooms.RoomsId);
            ViewData["TVSId"]   = new SelectList(_context.TVS, "TVSId", "Brand", tVSInRooms.TVSId);
            return(View(tVSInRooms));
        }