/// <summary> /// Method for obtaining the necessary data. /// </summary> /// <param name="numberOfSession"></param> /// <returns></returns> public IEnumerable <SessionResultRow> GetResult(int numberOfSession) { var groups = groupDao.ReadAll(); var subjects = subjectDao.ReadAll(); var students = studentDao.ReadAll(); var exams = examDao.ReadAll(); var results = resultDao.ReadAll(); List <SessionResultRow> sessionResults = new List <SessionResultRow>(); foreach (Group cgroup in groups) { var summaryResults = from result in results join exam in exams on result.IdExam equals exam.Id where exam.NumberOfSession == numberOfSession & exam.IdGroup == cgroup.Id select result; var averageMark = summaryResults.Average(r => r.Mark); var minMark = summaryResults.Min(r => r.Mark); var maxMark = summaryResults.Max(r => r.Mark); sessionResults.Add(new SessionResultRow { GroupName = cgroup.Name, AverageMark = averageMark, MinMark = minMark, MaxMark = maxMark }); } return(sessionResults); }
/// <summary> /// Method for obtaining the necessary data. /// </summary> /// <param name="groupName"></param> /// <param name="numberOfSession"></param> /// <returns></returns> public IEnumerable <StudentResult> GetResult(string groupName, int numberOfSession) { var groups = groupDao.ReadAll(); var subjects = subjectDao.ReadAll(); var students = studentDao.ReadAll(); var exams = examDao.ReadAll(); var results = resultDao.ReadAll(); var groupWithId = groups.FirstOrDefault(x => x.Name == groupName); var sessionResults = from student in students join result in results on student.Id equals result.IdStudent join exam in exams on result.IdExam equals exam.Id join subject in subjects on exam.IdSubject equals subject.Id where student.IdGroup == groupWithId.Id & exam.NumberOfSession == numberOfSession select new StudentResult { FirstName = student.FirstName, MiddleName = student.MiddleName, LastName = student.LastName, DateOfBirth = student.DateOfBirth, Gender = student.Gender, Date = exam.Date, SubjectName = subject.Name, ExamType = exam.Type, Mark = result.Mark }; return(sessionResults); }