public async Task <IActionResult> Edit(int id, [Bind("Id,CourseName,TotalCredits")] 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(int id, [Bind("Id,StudentId,CourseId,StartDate,EndDate")] Enrolment enrolment) { if (id != enrolment.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(enrolment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EnrolmentExists(enrolment.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CourseId"] = new SelectList(_context.Course, "Id", "Id", enrolment.CourseId); ViewData["StudentId"] = new SelectList(_context.Set <Student>(), "Id", "Id", enrolment.StudentId); return(View(enrolment)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email,Phone,Password")] Student student) { if (id != student.Id) { return(NotFound()); } if (ModelState.IsValid) { try { var user = await _userManager.FindByEmailAsync(student.Email); if (student.Password != null) { user.PasswordHash = _userManager.PasswordHasher.HashPassword(user, student.Password); } await _userManager.UpdateAsync(user); _context.Update(student); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(student.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(student)); }