public async Task <IActionResult> Edit(int id, [Bind("idTerminu,terminKonani,dobaTrvani,idJazyka,idSkoleni,idMistnosti")] Termin termin) { ViewData["adminVolba"] = 4; if (id != termin.idTerminu) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(termin); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TerminExists(termin.idTerminu)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["idJazyka"] = new SelectList(_context.seznamJazyku, "idJazyka", "idJazyka", termin.idJazyka); ViewData["idMistnosti"] = new SelectList(_context.seznamMistnosti, "idMistnosti", "idMistnosti", termin.idMistnosti); ViewData["idSkoleni"] = new SelectList(_context.seznamSkoleni, "idSkoleni", "idSkoleni", termin.idSkoleni); return(View(TerminyServ.getTerminFillViewModel(_context, termin))); }
public async Task <IActionResult> Edit(int?id) { ViewData["adminVolba"] = 4; if (id == null) { return(NotFound()); } var termin = await _context.seznamTerminu.FindAsync(id); if (termin == null) { return(NotFound()); } TerminViewModel vm = TerminyServ.getTerminFillViewModel(_context, termin); return(View(vm)); }