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