public IActionResult EditStudentGrades(int StudentId, List <EditStudentGradesViewModel> model) { if (ModelState.IsValid) { foreach (var item in model) { if (studentCourseRepository.IsRelationExist(StudentId, item.CourseId)) { StudentCourseRelation studentCourse = studentCourseRepository.GetReltionById(StudentId, item.CourseId); studentCourse.GPA = item.CourseGPA; studentCourseRepository.Update(studentCourse); } else { return(View("CourseStudentError")); } } return(RedirectToAction("Details", new { id = StudentId })); } return(View(model)); }