private ICollection <UserEntity> SetBuyItemAnnouncementReceivers(string senderId) { var senderCourses = _courseOfStudyService.GetStudentCourses(senderId); var receivers = new List <UserEntity>(); foreach (var course in senderCourses) { var sameCourses = _studentExchangeDataContext.CoursesOfStudy.Include(c => c.Groups) .Include(c => c.Faculty).ToList().FindAll(c => c.Faculty.Id == course.Faculty.Id && c.Name == course.Name); var yearFilteredCourses = sameCourses.Where(c => int.Parse(c.StartYear) <= int.Parse(course.StartYear)); foreach (var fcourse in yearFilteredCourses) { foreach (var group in fcourse.Groups) { receivers.AddRange(group.Students); } } } receivers.RemoveAll(r => r.Id == senderId); return(receivers.Distinct().ToList()); }
public IHttpActionResult GetStudentCourses(string studentId) { return(Content(HttpStatusCode.OK, _courseOfStudyService.GetStudentCourses(studentId))); }