public JsonResult GetCourses(int id)
        {
            _request_queue.Send(id, "Details - DegreePrograms");
            SerializableModels.DegreeProgram dp = (GetMessage(typeof(SerializableModels.DegreeProgram[])) as SerializableModels.DegreeProgram[])[0];

            DegreeProgram degreeprogram = (DegreeProgram)MessageHandler.GetRegularObject(typeof(DegreeProgram), dp);

            if (degreeprogram != null)
            {
                List<FlowchartCourse> results = new List<FlowchartCourse>();
                Dictionary<int, int> semesterOrders = new Dictionary<int, int>();
                for (int i = 1; i <= 8; i++)
                {
                    semesterOrders[i] = 0;
                }

                List<RequiredCourse> requirements = degreeprogram.requiredCourses.ToList();
                foreach (RequiredCourse req in requirements)
                {
                    FlowchartCourse pcourse = new FlowchartCourse();
                    pcourse.pcourseID = req.ID;
                    pcourse.courseID = req.courseID;
                    pcourse.courseTitle = req.course.courseCatalogNumber;
                    pcourse.courseName = req.course.courseTitle;
                    int order = semesterOrders[req.semester];
                    pcourse.order = order;
                    semesterOrders[req.semester] = order + 1;
                    pcourse.semester = req.semester;
                    pcourse.hours = req.course.shortHours;
                    pcourse.prereq = new int[req.course.prerequisites.Count];
                    int place = 0;
                    foreach (PrerequisiteCourse prereq in req.course.prerequisites)
                    {
                        pcourse.prereq[place++] = prereq.prerequisiteCourseID;
                    }
                    results.Add(pcourse);
                }

                List<ElectiveCourse> elects = degreeprogram.electiveCourses.ToList();
                foreach (ElectiveCourse elect in elects)
                {
                    FlowchartCourse pcourse = new FlowchartCourse();
                    pcourse.pcourseID = elect.ID;
                    pcourse.elistID = elect.electiveListID;
                    pcourse.elistName = elect.electiveList.shortName;
                    int order = semesterOrders[elect.semester];
                    pcourse.order = order;
                    semesterOrders[elect.semester] = order + 1;
                    pcourse.semester = elect.semester;
                    pcourse.hours = elect.credits.ToString();
                    results.Add(pcourse);
                }
                return Json(results.ToArray(), JsonRequestBehavior.AllowGet);
            }
            return Json(null);
        }
Beispiel #2
0
 public JsonResult GetPlanCourses(int id)
 {
     _request_queue.Send(id, "Details - Plans");
     SerializableModels.Plan pl = (GetMessage(typeof(SerializableModels.Plan[])) as SerializableModels.Plan[])[0];
     Plan plan = (Plan)MessageHandler.GetRegularObject(typeof(Plan), pl);
     if (webSecurity.CurrentUser.IsInRole("Advisor") || plan.userID == webSecurity.CurrentUserId){
         List<FlowchartCourse> results = new List<FlowchartCourse>();
         foreach (PlanCourse pcourse in plan.planCourses)
         {
             FlowchartCourse here = new FlowchartCourse();
             here.order = pcourse.order;
             here.semester = pcourse.semesterID;
             here.hours = pcourse.credits;
             here.pcourseID = pcourse.ID;
             if (pcourse.courseID != null)
             {
                 here.courseID = (int)pcourse.courseID;
                 here.courseTitle = pcourse.course.courseCatalogNumber;
                 here.courseName = pcourse.course.courseTitle;
                 here.prereq = new int[pcourse.course.prerequisites.Count];
                 int place = 0;
                 foreach(PrerequisiteCourse prereq in pcourse.course.prerequisites){
                     here.prereq[place++] = prereq.prerequisiteCourseID;
                 }
             }
             if (pcourse.electiveListID != null)
             {
                 here.elistID = (int)pcourse.electiveListID;
                 here.elistName = pcourse.electiveList.shortName;
             }
             results.Add(here);
         }
         return Json(results.ToArray(), JsonRequestBehavior.AllowGet);
     }
     return Json(null);
 }
        public JsonResult GetCourses(int id)
        {
            //DegreeProgram degreeProgram = degreePrograms.Find(id);
            DegreeProgram degreeProgram = _degreeProgramProducer.Get(new DegreeProgram() { ID = id });
            if (degreeProgram != null)
            {
                List<FlowchartCourse> results = new List<FlowchartCourse>();
                Dictionary<int, int> semesterOrders = new Dictionary<int, int>();
                for (int i = 1; i <= 8; i++)
                {
                    semesterOrders[i] = 0;
                }

                List<RequiredCourse> requirements = degreeProgram.requiredCourses.ToList();
                foreach (RequiredCourse req in requirements)
                {
                    FlowchartCourse pcourse = new FlowchartCourse();
                    pcourse.pcourseID = req.ID;
                    pcourse.courseID = req.courseID;
                    pcourse.courseTitle = req.course.courseCatalogNumber;
                    pcourse.courseName = req.course.courseTitle;
                    int order = semesterOrders[req.semester];
                    pcourse.order = order;
                    semesterOrders[req.semester] = order + 1;
                    pcourse.semester = req.semester;
                    pcourse.hours = req.course.shortHours;
                    pcourse.prereq = new int[req.course.prerequisites.Count];
                    int place = 0;
                    foreach (PrerequisiteCourse prereq in req.course.prerequisites)
                    {
                        pcourse.prereq[place++] = prereq.prerequisiteCourseID;
                    }
                    results.Add(pcourse);
                }

                List<ElectiveCourse> elects = degreeProgram.electiveCourses.ToList();
                foreach (ElectiveCourse elect in elects)
                {
                    FlowchartCourse pcourse = new FlowchartCourse();
                    pcourse.pcourseID = elect.ID;
                    pcourse.elistID = elect.electiveListID;
                    pcourse.elistName = elect.electiveList.shortName;
                    int order = semesterOrders[elect.semester];
                    pcourse.order = order;
                    semesterOrders[elect.semester] = order + 1;
                    pcourse.semester = elect.semester;
                    pcourse.hours = elect.credits.ToString();
                    results.Add(pcourse);
                }
                return Json(results.ToArray(), JsonRequestBehavior.AllowGet);
            }
            return Json(null);
        }
 public JsonResult GetPlanCourses(int id)
 {
     //Plan plan = plans.Find(id);
     Plan plan = _planProducer.Get(new Plan() { ID = id });
     if (webSecurity.CurrentUser.IsInRole("Advisor") || plan.userID == webSecurity.CurrentUserId){
         List<FlowchartCourse> results = new List<FlowchartCourse>();
         foreach (PlanCourse pcourse in plan.planCourses)
         {
             FlowchartCourse here = new FlowchartCourse();
             here.order = pcourse.order;
             here.semester = pcourse.semesterID;
             here.hours = pcourse.credits;
             here.pcourseID = pcourse.ID;
             if (pcourse.courseID != null)
             {
                 here.courseID = (int)pcourse.courseID;
                 here.courseTitle = pcourse.course.courseCatalogNumber;
                 here.courseName = pcourse.course.courseTitle;
                 here.prereq = new int[pcourse.course.prerequisites.Count];
                 int place = 0;
                 foreach(PrerequisiteCourse prereq in pcourse.course.prerequisites){
                     here.prereq[place++] = prereq.prerequisiteCourseID;
                 }
             }
             if (pcourse.electiveListID != null)
             {
                 here.elistID = (int)pcourse.electiveListID;
                 here.elistName = pcourse.electiveList.shortName;
             }
             results.Add(here);
         }
         return Json(results.ToArray(), JsonRequestBehavior.AllowGet);
     }
     return Json(null);
 }