public async Task <IActionResult> Edit(int id, [Bind("Id,DepartureTime,Destination,DistanceKm")] TrainSchedule trainSchedule) { if (id != trainSchedule.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(trainSchedule); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TrainScheduleExists(trainSchedule.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(trainSchedule)); }