public async Task <IActionResult> Edit(int id, [Bind("GedimasId,registravimoLaikas,Apibudinimas,DviratisId,KlientasId")] Gedimas gedimas) { if (id != gedimas.GedimasId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(gedimas); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GedimasExists(gedimas.GedimasId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DviratisId"] = new SelectList(_context.Dviratis, "DviratisId", "DviratisId", gedimas.DviratisId); ViewData["KlientasId"] = new SelectList(_context.Set <Klientas>(), "KlientasId", "KlientasId", gedimas.KlientasId); return(View(gedimas)); }
public async Task <IActionResult> Create([Bind("GedimasId,registravimoLaikas,Apibudinimas,DviratisId,KlientasId")] Gedimas gedimas) { if (ModelState.IsValid) { _context.Add(gedimas); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DviratisId"] = new SelectList(_context.Dviratis, "DviratisId", "DviratisId", gedimas.DviratisId); ViewData["KlientasId"] = new SelectList(_context.Set <Klientas>(), "KlientasId", "KlientasId", gedimas.KlientasId); return(View(gedimas)); }