public async Task <IActionResult> Edit(short id, [Bind("Idservicos,Idhotel,Descricao")] ServicosHotel servicosHotel) { if (id != servicosHotel.Idservicos) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(servicosHotel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ServicosHotelExists(servicosHotel.Idservicos)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Idhotel"] = new SelectList(_context.Hoteis, "Idhotel", "CodPostal", servicosHotel.Idhotel); return(View(servicosHotel)); }
public async Task <IActionResult> Create([Bind("Idservicos,Idhotel,Descricao")] ServicosHotel servicosHotel) { if (ModelState.IsValid) { _context.Add(servicosHotel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Idhotel"] = new SelectList(_context.Hoteis, "Idhotel", "CodPostal", servicosHotel.Idhotel); return(View(servicosHotel)); }