public async Task <IActionResult> Edit(int id, [Bind("ID,FirstName,LastName,Age")] 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)); }
public async Task <IActionResult> Edit(int id, [Bind("CourseID,StudentID")] Enrollments enrollments) { if (id != enrollments.StudentID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(enrollments); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EnrollmentsExists(enrollments.StudentID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CourseID"] = new SelectList(_context.Courses, "ID", "ID", enrollments.CourseID); ViewData["StudentID"] = new SelectList(_context.Students, "ID", "ID", enrollments.StudentID); return(View(enrollments)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,CourseCode,Technology,Price")] 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 IActionResult Update(Enrollment r) { _context.Update(r); _context.SaveChanges(); return(RedirectToAction("Details")); }