/// <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); } } }
public void OrderAndTake(string courseName, string comparison, 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]); sorter.OrderAndTake(grades, comparison, studentsToTake.Value); } }
public void OrderAndTake(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]); sorter.OrderAndTake(marks, givenFilter, studentsToTake.Value); } }
public void OrderAndTake(string courseName, string comparison, int?studentsToTake = null) { if (IsQueryFromCoursePossible(courseName)) { if (studentsToTake == null) { studentsToTake = this.courses[courseName].StudentsByName.Count; } Dictionary <string, double> marks = this.courses[courseName].StudentsByName .ToDictionary(x => x.Key, x => x.Value.MarksByCourseName[courseName]); sorter.OrderAndTake(marks, comparison, studentsToTake.Value); } }