public List <ScoreList> GetCourseList(int id) { List <ScoreList> socrelist = new List <ScoreList>(); var student = studentRepository.Query(id); var scoreList = scoreRepository.Query(id); double tempCredit = 0; student.StuCrdit = tempCredit.ToString(); studentRepository.Update(student); for (int i = 0; i < scoreList.Count; i++) { var course = courseRepository.Query(scoreList[i].CcourseCode); ScoreList temp = new ScoreList(); temp.id = scoreList[i].CstuId; temp.coursecode = course.CourseCode; temp.coursecredit = course.CourseCredit; temp.coursename = course.CourseName; temp.name = student.StuName; if (scoreList[i].CourseScore == null) { temp.coursescore = 0; } else { temp.coursescore = (double)scoreList[i].CourseScore; } temp.coursetype = course.CourseType; if (temp.coursescore >= 60) { tempCredit += temp.coursecredit; } socrelist.Add(temp); } student.StuCrdit = tempCredit.ToString(); studentRepository.Update(student); ScoreList temp2 = new ScoreList(); temp2.id = student.StuId; temp2.name = student.StuName; socrelist.Insert(0, temp2); return(socrelist); }