コード例 #1
0
ファイル: CourseConverter.cs プロジェクト: weedkiller/NINE
        internal void ConvertDates(CourseSummaryDto summary, Course course)
        {
            foreach (var activityDate in course.Dates)
            {
                var courseDate = ConvertDate(activityDate);

                if (summary.Dates == null)
                {
                    summary.Dates = new List <CourseDateDto>();
                }

                summary.Dates.Add(courseDate);
            }
        }
コード例 #2
0
ファイル: CourseConverter.cs プロジェクト: weedkiller/NINE
        /// <summary>
        ///
        /// </summary>
        public CourseSummaryDto ConvertSummary(Course course)
        {
            var dto = new CourseSummaryDto();

            var courseService = new CourseService(_db);

            var summary = courseService.GetCourseSummary(course);

            dto.Id          = course.Id;
            dto.Name        = course.Name;
            dto.ShortName   = course.ShortName;
            dto.Description = course.Description;
            dto.IsCoterie   = course.Occurrence.IsCoterie;
            dto.HasHomeBias = course.Occurrence.HasHomeBias;

            foreach (var host in summary.Lecturers)
            {
                var lecturer = new LecturerDto();
                lecturer.FirstName = host.FirstName;
                lecturer.LastName  = host.Name;
                lecturer.Title     = host.Title;

                if (!string.IsNullOrEmpty(host.UrlProfile))
                {
                    lecturer.AddAction("Profile", host.UrlProfile);
                }

                if (dto.Lecturer == null)
                {
                    dto.Lecturer = new List <LecturerDto>();
                }

                dto.Lecturer.Add(lecturer);
            }

            foreach (var room in summary.Rooms)
            {
                var courseRoom = new RoomDto();

                courseRoom.Number   = room.Number;
                courseRoom.Building = room.Number.Substring(0, 1);

                if (courseRoom.Number.StartsWith("K") || courseRoom.Number.StartsWith("L"))
                {
                    courseRoom.Campus = "Pasing";
                }
                else if (courseRoom.Number.StartsWith("F"))
                {
                    courseRoom.Campus = "Karlstrasse";
                }
                else
                {
                    courseRoom.Campus = "Lothstrasse";
                }

                if (dto.Locations == null)
                {
                    dto.Locations = new List <RoomDto>();
                }

                dto.Locations.Add(courseRoom);
            }

            foreach (var activityDate in summary.Dates)
            {
                var courseDate = new AppointmentDto();

                courseDate.DayOfWeekName = activityDate.DayOfWeek.ToString();
                courseDate.TimeBegin     = activityDate.StartTime.ToString();
                courseDate.TimeEnd       = activityDate.EndTime.ToString();

                if (dto.Appointments == null)
                {
                    dto.Appointments = new List <AppointmentDto>();
                }

                dto.Appointments.Add(courseDate);
            }


            foreach (var nexus in course.Nexus)
            {
                var module = new ModuleDto();

                var curr = new CurriculumDto();

                curr.Name      = nexus.Requirement.Option.Package.Curriculum.Name;
                curr.ShortName = nexus.Requirement.Option.Package.Curriculum.ShortName;

                curr.Organiser           = new OrganiserDto();
                curr.Organiser.Name      = nexus.Requirement.Option.Package.Curriculum.Organiser.Name;
                curr.Organiser.ShortName = nexus.Requirement.Option.Package.Curriculum.Organiser.ShortName;
                curr.Organiser.Color     = nexus.Requirement.Option.Package.Curriculum.Organiser.HtmlColor;

                module.Id         = nexus.Requirement.Id;
                module.Curriculum = curr;
                module.Ects       = nexus.Requirement.ECTS;
                module.UsCredits  = nexus.Requirement.USCredits;
                module.Sws        = nexus.Requirement.SWS;


                if (dto.Modules == null)
                {
                    dto.Modules = new List <ModuleDto>();
                }

                dto.Modules.Add(module);
            }



            return(dto);
        }