public async Task <IActionResult> Edit(int id, [Bind("CourseID,Title,Credits")] Course course) { if (id != course.CourseID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(course); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseExists(course.CourseID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(course)); }
public async Task <IActionResult> Edit(int id, [Bind("EnrollmentID,CourseID,StudentID,Grade")] 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.Course, "CourseID", "CourseID", enrollment.CourseID); ViewData["StudentID"] = new SelectList(_context.Student, "ID", "ID", enrollment.StudentID); return(View(enrollment)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,LastName,FirstName,EnrollmentDate")] Student student) { if (id != student.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(student); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(student.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(student)); }