コード例 #1
0
ファイル: CoursesController.cs プロジェクト: weedkiller/NINE
        public IQueryable <CourseSummaryDto> GetCourseSummaries(string organiser, string curriculum, string semester)
        {
            var list = new List <CourseSummaryDto>();

            var org = Db.Organisers.SingleOrDefault(x => x.ShortName.Equals(organiser));

            if (org == null)
            {
                return(list.AsQueryable());
            }

            var curr = org.Curricula.FirstOrDefault(x => x.ShortName.Equals(curriculum));

            if (curr == null)
            {
                return(list.AsQueryable());
            }

            var sem = Db.Semesters.SingleOrDefault(x => x.Name.Equals(semester));

            if (sem == null)
            {
                return(list.AsQueryable());
            }

            var allCourses = Db.Activities.OfType <Course>().Where(x =>
                                                                   x.SemesterGroups.Any(g =>
                                                                                        g.CapacityGroup.CurriculumGroup.Curriculum.Id == curr.Id && g.IsAvailable &&
                                                                                        g.Semester.Id == sem.Id)).ToList();

            var converter = new CourseConverter(Db);

            foreach (var course in allCourses)
            {
                list.Add(converter.ConvertSummary(course));
            }

            return(list.AsQueryable());
        }
コード例 #2
0
        public IQueryable <CourseSummaryDto> GetCourses(string semester)
        {
            var list = new List <CourseSummaryDto>();

            var sem = Db.Semesters.FirstOrDefault(x => x.Name.Equals(semester));

            if (sem == null)
            {
                return(list.AsQueryable());
            }

            var courses = Db.Activities.OfType <Course>().Where(x => x.SemesterGroups.Any(g =>
                                                                                          g.IsAvailable && g.Semester.Id == sem.Id && g.CapacityGroup.CurriculumGroup.Curriculum.ShortName.StartsWith("CIE"))).ToList();

            var converter = new CourseConverter(Db);

            foreach (var course in courses)
            {
                var summary = converter.ConvertSummary(course);

                converter.ConvertDates(summary, course);


                // Sonderlocken
                if (summary.IsCoterie)
                {
                    summary.Category = "Red";
                }
                else
                {
                    if (summary.HasHomeBias)
                    {
                        summary.Category = "Yellow";
                    }
                    else
                    {
                        summary.Category = "Green";
                    }
                }

                var isBachelor = course.SemesterGroups.Any(g =>
                                                           g.CapacityGroup.CurriculumGroup.Curriculum.ShortName.Equals("CIE-B"));

                var isMaster = course.SemesterGroups.Any(g =>
                                                         g.CapacityGroup.CurriculumGroup.Curriculum.ShortName.Equals("CIE-M"));

                if (isBachelor && isMaster)
                {
                    summary.Level = "Bachelor / Master";
                }
                else
                {
                    summary.Level = "none";

                    if (isBachelor)
                    {
                        summary.Level = "Bachelor";
                    }

                    if (isMaster)
                    {
                        summary.Level = "Master";
                    }
                }

                var group = course.SemesterGroups.FirstOrDefault(x =>
                                                                 x.CapacityGroup.CurriculumGroup.Curriculum.ShortName.StartsWith("CIE"));

                var org = group.CapacityGroup.CurriculumGroup.Curriculum.Organiser;

                summary.Department           = new OrganiserDto();
                summary.Department.Name      = org.Name;
                summary.Department.ShortName = org.ShortName;
                summary.Department.Color     = org.HtmlColor;


                summary.Sws       = 4;
                summary.Ects      = 5;
                summary.UsCredits = 4;


                list.Add(summary);
            }

            return(list.AsQueryable());
        }