public void addStudent(UserAccount student) { if (!student.Id.HasValue || !this.Id.HasValue) { return; } if (StudentLinks.Any(link => link.UserAccountId == student.Id)) { return; } StudentLinks.Add(new UserAccountToCourseLink() { Course = this, CourseId = this.Id.Value, UserAccount = student, UserAccountId = student.Id.Value }); }
public void removeStudent(UserAccount student) { if (!student.Id.HasValue || !this.Id.HasValue) { return; } foreach (var link in StudentLinks) { if (link.UserAccountId == student.Id) { StudentLinks.Remove(link); return; } } }
public ICollection <UserAccount> GetStudents() { return(StudentLinks.Select(link => link.UserAccount).ToList()); }