public static bool AddSelectedStudent(SelectedStudent std) { // check if student is not already selected foreach (SelectedStudent s in selectedStudents) { // check on uniquely identified email address if (s.email_id.Equals(std.email_id)) { return(false); } } // otherwise insert in the list of selected students selectedStudents.Add(std); // Code to insert into database return(true); }
// core algorithm to generate the merit list public static void GenerateMeritList() { // Sorting Students Applications On the Basis of Merit List <StudentApplication> ApplicationsSortedList = APPLICATION.applications.OrderByDescending(o => o.aggregate).ToList(); // go through all student applications foreach (StudentApplication app in ApplicationsSortedList) { // go through the selectd preferences of the student // if not selected in first preference foreach (Preference p in app.preferences) { // get the Department object to check the seats quota Department d = departments.Single(o => o.dept_name.Equals(p.pref_dept_name)); if (d.dept_seats_quota != 0) { // create new object of selected Student to add in the list SelectedStudent selected = new SelectedStudent(); selected.ARN = app.app_ref_number; selected.email_id = app.std_email; selected.father_name = app.std_father_name; selected.name = app.student_name; selected.aggregate = app.aggregate; selected.department = p.pref_dept_name; // add student to the list of selected students selectedStudents.Add(selected); // change the remaining seats in the departments foreach (Department dpt in departments) { if (dpt.dept_name.Equals(d.dept_name)) { dpt.dept_seats_quota = dpt.dept_seats_quota - 1; break; } } break; } } } }