public async Task <IActionResult> Edit(int id, [Bind("StudentId,LastName,FirstName,EnrollmentDate")] Student student) { if (id != student.StudentId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(student); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(student.StudentId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(student)); }
public async Task <IActionResult> Edit(int id, [Bind("EnrollmentId,Grade,CourseId,StudentId")] Enrollment enrollment) { if (id != enrollment.EnrollmentId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(enrollment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EnrollmentExists(enrollment.EnrollmentId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CourseId"] = new SelectList(_context.Courses, "CourseId", "CourseId", enrollment.CourseId); ViewData["StudentId"] = new SelectList(_context.Students, "StudentId", "StudentId", enrollment.StudentId); return(View(enrollment)); }