Esempio n. 1
0
        /// <summary>
        /// Gets students but also does filtering query on them
        /// </summary>
        /// <param name="courseName"></param>
        /// <param name="sorting">Choose either Filtering or Ordering</param>
        /// <param name="criteria">Filtering - by performance, Sorting - Ascending, Descending</param>
        /// <param name="takeNumber">Amount of items to take</param>
        public void GetAllStudentsFromCourse(string courseName, SortingOperation sorting, string criteria = null, int takeNumber = -1)
        {
            if (sorting == SortingOperation.None)
            {
                GetAllStudentsFromCourse(courseName);
            }
            else if (IsQueryForCoursePossible(courseName))
            {
                //Extract the student names and their marks
                var studentsWithMarks = courses[courseName].StudentsByName.ToDictionary(k => k.Key, v => v.Value.MarksByCourseName[courseName]);

                if (sorting == SortingOperation.Filter)
                {
                    studentsWithMarks = filter.FilterAndTake(studentsWithMarks, criteria, takeNumber) as Dictionary <string, double>;
                }

                else if (sorting == SortingOperation.Order)
                {
                    studentsWithMarks = sorter.OrderAndTake(studentsWithMarks, criteria, takeNumber) as Dictionary <string, double>;
                }

                if (studentsWithMarks is null)
                {
                    return;
                }

                foreach (var student in studentsWithMarks)
                {
                    OutputWriter.PrintStudent(student);
                }
            }
        }
Esempio n. 2
0
 public void FilterAndTake(string courseName, string givenFilter, int?studentsToTake = null)
 {
     if (IsQueryForCoursePossible(courseName))
     {
         if (studentsToTake == null)
         {
             studentsToTake = this.courses[courseName].StudentsByName.Count;
         }
         var grades = this.courses[courseName].StudentsByName
                      .ToDictionary(x => x.Key, x => x.Value.GradesByCourseName[courseName]);
         filter.FilterAndTake(grades, givenFilter, studentsToTake.Value);
     }
 }
Esempio n. 3
0
        public void FilterAndTake(string courseName, string givenFilter, int?studentsToTake = null)
        {
            if (IsQueryForCoursePossible(courseName))
            {
                if (studentsToTake == null)
                {
                    studentsToTake = courses[courseName].StudentsByName.Count;
                }

                Dictionary <string, double> marks = courses[courseName].StudentsByName.ToDictionary(x => x.Key, x => x.Value.MarksByCourseName[courseName]);

                filter.FilterAndTake(marks, givenFilter, studentsToTake.Value);
            }
        }