Exemple #1
0
        public async Task <IActionResult> Create([Bind("Id,RoomNumber,Description,RoomType,RoomSize")] Room room)
        {
            if (ModelState.IsValid)
            {
                _context.Add(room);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(room));
        }
        public async Task <IActionResult> Create([Bind("Id,StartDate,EndDate,ApplicationUserId,RoomId")] Booking booking)
        {
            if (ModelState.IsValid)
            {
                _context.Add(booking);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ApplicationUserId"] = new SelectList(_context.Users, "Id", "Id", booking.ApplicationUserId);
            ViewData["RoomId"]            = new SelectList(_context.Room, "Id", "RoomNumber", booking.RoomId);
            return(View(booking));
        }