/// <summary> /// Method to make course directory /// </summary> /// <returns>Course Dictionary</returns> public Dictionary <int, Dictionary <int, int> > CreateCourseDictionary() { Dictionary <int, Dictionary <int, int> > courseDic = new Dictionary <int, Dictionary <int, int> >(); List <int> ansList = new List <int>(); List <CourseTopic> ctList = db.GetCourseTopics(); foreach (CourseTopic ct in ctList) { Dictionary <int, int> tpDic = new Dictionary <int, int>(); if (courseDic.ContainsKey(ct.CourseId)) { tpDic = courseDic[ct.CourseId]; tpDic.Add(ct.TopicId, ct.Percentage); } else { tpDic.Add(ct.TopicId, ct.Percentage); courseDic.Add(ct.CourseId, tpDic); } } for (int i = 1; i <= 11; i++) { Dictionary <int, int> tempDic = courseDic[i]; courseDic[i] = tempDic.OrderByDescending(d => d.Value).ToDictionary(d => d.Key, d => d.Value); } return(courseDic); }
static void Main(string[] args) { MyDb db = new MyDb(); Course course = new Course(); Topic topic = new Topic(); Expertise expert = new Expertise(); Professor professor = new Professor(); CourseTopic courseTopic = new CourseTopic(); List <Professor> professors = db.GetProfessors(); List <Course> courses = db.GetCourses(); List <Topic> topics = db.GetTopics(); List <Expertise> experts = db.GetExpertise(); List <CourseTopic> courseTopics = db.GetCourseTopics(); PrintData(courses, topics, professors, experts, courseTopics); GetWeightedTopics(courses, courseTopics); Analyser analyser = new Analyser(); Console.WriteLine(""); Console.WriteLine("----------- Result --------------"); Dictionary <int, Dictionary <int, int> > dic = analyser.CreateCourseDictionary(); List <int> profPerList = new List <int>(); for (int courseID = 1; courseID < 12; courseID++) { profPerList = analyser.GetProfessorForCourse(courseID); Console.WriteLine("Course Id :{0} Professor {1} Percentage : {2}", courseID, profPerList[0], profPerList[1] / 100); } Console.ReadLine(); }