Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("CheckInsModelId,RoomId,Date,AdultCount,ChildCount")] CheckInsModel checkInsModel)
        {
            if (id != checkInsModel.CheckInsModelId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(checkInsModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CheckInsModelExists(checkInsModel.CheckInsModelId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RoomId"] = new SelectList(_context.BreakfastBookings, "RoomId", checkInsModel.RoomId.ToString());
            ViewData["Date"]   = new SelectList(_context.BreakfastBookings, "Date", checkInsModel.Date);
            //ViewBag.RoomId = new SelectList(_context.BreakfastBookings, "RoomId", checkInsModel.RoomId.ToString());
            //ViewBag.Date = new SelectList(_context.BreakfastBookings, "Date", checkInsModel.Date);
            return(View(checkInsModel));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("CheckInsModelId,RoomId,Date,AdultCount,ChildCount")] CheckInsModel checkInsModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(checkInsModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RoomId"] = new SelectList(_context.BreakfastBookings, "RoomId", checkInsModel.RoomId.ToString());
            ViewData["Date"]   = new SelectList(_context.BreakfastBookings, "Date", checkInsModel.Date);
            return(View(checkInsModel));
        }