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)); }
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)); }