public Student Assign(int stuId, int couId) { Student student = Find(stuId); foreach (var course in student.PersonCourses) { if (course.Course.Id == couId) { return(student); } } PersonCourse personCourse = new PersonCourse { CourseId = couId, StudentId = stuId }; return(_studentRepository.Assign(personCourse)); }