public ICollection <ItemAnnouncement> GetItemAnnouncements(string receiverId)
 {
     return((from i in _studentExchangeDataContext.Announcements.OfType <ItemAnnouncement>() select i).ToList().FindAll(i => i.Receivers.Contains(_studentExchangeDataContext.GetUserById(receiverId))));
 }
        public ICollection <University> GetStudentUniversities(string studentId)
        {
            var groups = _studentExchangeDataContext.Groups.ToList().FindAll(g =>
                                                                             g.Students.Contains(_studentExchangeDataContext.GetUserById(studentId)));
            var courses      = groups.Select(@group => _studentExchangeDataContext.CoursesOfStudy.ToList().Find(c => c.Groups.Contains(@group))).ToList();
            var faculties    = courses.Select(course => _studentExchangeDataContext.Faculties.ToList().Find(f => f.CoursesOfStudy.Contains(course))).ToList();
            var universities = faculties.Select(faculty => _studentExchangeDataContext.Universities.ToList().Find(u => u.Faculties.Contains(faculty))).ToList();

            universities.RemoveAll(u => u == null);
            return(universities.Distinct().ToList());
        }
        public ICollection <CourseOfStudy> GetStudentCourses(string studentId)
        {
            var groups = _studentExchangeDataContext.Groups.Include(g => g.CourseOfStudy).ToList().FindAll(g =>
                                                                                                           g.Students.Contains(_studentExchangeDataContext.GetUserById(studentId)));
            var courses = groups.Select(@group => @group.CourseOfStudy).Distinct().ToList();

            var faculties = new List <Faculty>();

            foreach (var course in courses)
            {
                course.Faculty = _studentExchangeDataContext.Faculties.Include(f => f.CoursesOfStudy).ToList()
                                 .Find(f => f.CoursesOfStudy.Contains(course));
                faculties.Add(course.Faculty);
            }

            foreach (var faculty in faculties)
            {
                faculty.University = _studentExchangeDataContext.Universities.Include(u => u.Faculties).ToList()
                                     .Find(u => u.Faculties.Contains(faculty));
            }
            return(courses);
        }