public float GetGradesAverageInGroup(Group studentGroup) { float retVal = 0; int studentsCount = 0; ICollection <Student> students = studentsRepository.GetStudentsByGroupId(studentGroup.Id); foreach (Student student in students) { studentsCount++; retVal += GetStudentGradesAverage(student); } if (studentsCount > 0) { retVal = retVal / studentsCount; } return(retVal); }