Esempio n. 1
0
        public async Task <IActionResult> Add([Bind("Name,Descrtiption,Seats,Projector,Board")] Room room)
        {
            if (ModelState.IsValid)
            {
                _context.Add(room);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(room));
        }
Esempio n. 2
0
        public async Task <IActionResult> Add([Bind("Start,End,UserId,RoomId")] Reservation reservation, int?roomid)
        {
            reservation.Status = Status.Idle;
            if (ModelState.IsValid)
            {
                _context.Add(reservation);
                await _context.SaveChangesAsync();

                if (roomid == null)
                {
                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    return(Redirect($"/Rooms/Details/{roomid}"));
                }
            }
            ViewData["Status"] = new SelectList(Statuses, Statuses.ToString());
            ViewData["RoomId"] = new SelectList(_context.Rooms, "Id", "Name", reservation.RoomId);
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Name", reservation.UserId);
            return(View(reservation));
        }