private static string GetTitle(PublicDivision publicDivision)
        {
            var    language = CultureHelper.CurrentLanguage;
            string preamble = GetPreambleForTitle(publicDivision);

            return(String.Concat(preamble, " ", publicDivision.GetNameByLanguage(language)));
        }
 public static DivisionItemViewModel Build(PublicDivision publicDivision)
 {
     return(new DivisionItemViewModel
     {
         Oid = publicDivision.Oid,
         Name = publicDivision.GetNameByLanguage(CultureHelper.CurrentLanguage),
         Alias = publicDivision.Alias
     });
 }
Example #3
0
 public static Breadcrumb GetBreadcrumb(PublicDivision publicDivision, StudyProgram studyProgram)
 {
     return(new Breadcrumb()
     {
         BreadcrumbHelper.GetBreadcrumbRootItem(false),
         BreadcrumbHelper.GetBreadcrumbPublicDivisionItem(publicDivision, false),
         BreadcrumbHelper.GetBreadcrumbCourseItem(publicDivision, studyProgram, false),
         BreadcrumbHelper.GetBreadcrumbTimeTableItem()
     });
 }
        private static string GetPreambleForTitle(PublicDivision publicDivision)
        {
            bool isPlural = publicDivision.Name.Contains(",");

            if (isPlural)
            {
                return(Resources.Resources.Divisions);
            }
            else
            {
                return(Resources.Resources.Division);
            }
        }
Example #5
0
        public static StudentGroupItemViewModel Build(StudentGroup studentGroup, PublicDivision publicDivision)
        {
            var language      = CultureHelper.CurrentLanguage;
            var studyFormName = studentGroup.StudyPlan == null ?
                                String.Empty : studentGroup.StudyPlan.StudyForm.GetNameByLanguage(language);

            return(new StudentGroupItemViewModel
            {
                StudentGroupId = studentGroup.Id,
                StudentGroupName = studentGroup.Name,
                StudentGroupStudyForm = studyFormName,
                StudentGroupProfiles = GetStudentGroupProfilesString(studentGroup),
                PublicDivisionAlias = publicDivision.Alias
            });
        }
Example #6
0
        public static BreadcrumbItem GetBreadcrumbPublicDivisionItem(PublicDivision publicDivision, bool isActive)
        {
            var language = CultureHelper.CurrentLanguage;

            return(new BreadcrumbItem
            {
                IsActive = isActive,
                DisplayText = publicDivision.GetNameByLanguage(language),
                ActionName = "Show",
                ControllerName = "Division",
                RouteValues = new RouteValueDictionary(new Dictionary <string, object> {
                    { "alias", publicDivision.Alias }
                }),
                HtmlAttributes = null
            });
        }
Example #7
0
        public static BreadcrumbItem GetBreadcrumbCourseItem(PublicDivision publicDivision, StudyProgram studyProgram, bool isActive)
        {
            var language = CultureHelper.CurrentLanguage;

            return(new BreadcrumbItem
            {
                IsActive = isActive,
                DisplayText = GetCourseItemDisplayText(language, studyProgram),
                ActionName = "Show",
                ControllerName = "StudyProgram",
                RouteValues = new RouteValueDictionary(new Dictionary <string, object> {
                    { "publicDivisionAlias", publicDivision.Alias },
                    { "id", studyProgram.Id }
                }),
                HtmlAttributes = null
            });
        }
        public static AdmissionYearItemViewModel Build(
            IEnumerable <StudyProgram> studyPrograms,
            PublicDivision publicDivision)
        {
            var firstProgram = studyPrograms?.FirstOrDefault();

            if (firstProgram == null)
            {
                return(Empty);
            }

            return(new AdmissionYearItemViewModel
            {
                PublicDivisionAlias = publicDivision.Alias,
                StudyProgramIds = studyPrograms.Select(p => p.Id),
                YearName = firstProgram.AdmissionYear.Name,
                YearNumber = firstProgram.AdmissionYear.Number
            });
        }
        public static DivisionShowViewModel Build(PublicDivision publicDivision)
        {
            alias = publicDivision.Alias;
            var publicDivisionStudentGroups = publicDivision.StudentGroups;
            var language = CultureHelper.CurrentLanguage;

            var studyProgramNameLevelCombinations = publicDivisionStudentGroups.Where(sg => sg.StudyProgram != null)
                                                    .Select(sg => sg.StudyProgram)
                                                    .Distinct()
                                                    .GroupBy(sp => new {
                Name           = sp.GetNameByLanguage(language),
                StudyLevelName = sp.StudyLevel.GetNameByLanguage(language),
            })
                                                    .Select(g => new StudyProgramNameLevelCombination
            {
                Name           = g.Key.Name,
                StudyLevelName = g.Key.StudyLevelName,
                StudyPrograms  = g.AsEnumerable()
            })
                                                    .OrderBy(x => x.StudyLevelName);

            return(new DivisionShowViewModel
            {
                Title = GetTitle(publicDivision),
                StudyProgramsTitle = GetStudyProgramsTitle(studyProgramNameLevelCombinations),
                StudyProgramLevels = studyProgramNameLevelCombinations
                                     .GroupBy(x => x.StudyLevelName)
                                     .Select(g => StudyProgramLevelViewModel.Build(g.Key, g, publicDivision)),
                Breadcrumb = new Breadcrumb()
                {
                    BreadcrumbHelper.GetBreadcrumbRootItem(false),
                    new BreadcrumbItem
                    {
                        IsActive = true,
                        DisplayText = publicDivision.GetNameByLanguage(language)
                    }
                }
            });
        }
        public static StudentGroupEventsSemesterViewModel Build(StudentGroup studentGroup, PublicDivision publicDivision, int?autumn)
        {
            var autumnSemesterStartDate = new DateTime(studentGroup.CurrentStudyYear.Number, 8, 1);

            var semesterStartDate = (autumn == 1 || autumn == null && NowIsAutumnSemester())
                ? autumnSemesterStartDate
                : autumnSemesterStartDate.AddMonths(6);

            var semesterEndDate = semesterStartDate.AddMonths(6);

            var days = StudyEventsViewModelHelper.GetStudentGroupAggregatedEventsDays(studentGroup, null, semesterStartDate, semesterEndDate).ToList();

            return(new StudentGroupEventsSemesterViewModel
            {
                Autumn = autumn,
                PublicDivisionAlias = publicDivision.Alias,
                StudentGroupId = studentGroup.Id,
                StudentGroupDisplayName = GetStudentGroupDisplayName(studentGroup),
                TimeTableDisplayName = TimeTableHelper.GetStudentGroupTimeTableDisplayNameForCodeByLanguage(StudyEventsTimeTableKindCode.Primary, CultureHelper.CurrentLanguage),
                Days = days,
                Breadcrumb = GetBreadcrumb(publicDivision, studentGroup.StudyProgram),
                SemesterStartDate = semesterStartDate,
                SemesterEndDate = semesterEndDate,
                SemesterDurationDisplayText = $"{semesterStartDate:d MMMM yyyy} - {semesterEndDate:d MMMM yyyy}",
                IsSpringSemester = semesterStartDate.Month == 2,
                HasEvents = days.Any(seadivm => seadivm.DayStudyEvents.Any()),
            });
        }
Example #11
0
        public static StudyProgramCombinationViewModel Build(StudyProgramNameLevelCombination studyProgramCombination, PublicDivision publicDivision)
        {
            var admissionYears = studyProgramCombination.StudyPrograms
                                 .Where(sp => sp.ContingentUnits.Any(cu => cu is StudentGroup && !cu.IsArchived))
                                 .GroupBy(sp => sp.AdmissionYear)
                                 .Select(g => AdmissionYearItemViewModel.Build(g.AsEnumerable(), publicDivision))
                                 .OrderByDescending(x => x.YearNumber)
                                 .ToList();

            return(new StudyProgramCombinationViewModel
            {
                Name = studyProgramCombination.Name,
                AdmissionYears = admissionYears
            });
        }
        public static StudentGroupEventsPrimaryViewModel Build(StudentGroup studentGroup, PublicDivision publicDivision, DateTime?weekMonday)
        {
            var defaultWeekStart = DateTimeHelper.GetWeekStart(DateTime.Today);
            var weekStart        = weekMonday ?? defaultWeekStart;
            var weekEnd          = weekStart.AddDays(7);
            var language         = CultureHelper.CurrentLanguage;

            return(new StudentGroupEventsPrimaryViewModel
            {
                StudentGroupId = studentGroup.Id,
                StudentGroupDisplayName = GetStudentGroupDisplayName(studentGroup),
                TimeTableDisplayName = TimeTableHelper.GetStudentGroupTimeTableDisplayNameForCodeByLanguage(StudyEventsTimeTableKindCode.Primary, language),
                WeekDisplayText = DateTimeHelper.GetWeekDisplayText(language, weekStart, weekEnd),
                PreviousWeekMonday = DateTimeHelper.GetDateStringForWeb(weekStart.AddDays(-7)),
                WeekMonday = DateTimeHelper.GetDateStringForWeb(weekStart),
                NextWeekMonday = DateTimeHelper.GetDateStringForWeb(weekEnd),
                IsCurrentWeekReferenceAvailable = (defaultWeekStart != weekStart),
                Days = StudyEventsViewModelHelper.GetStudyEventsDaysViewModelsForDateRange(studentGroup, null, weekStart, weekEnd),
                Breadcrumb = GetBreadcrumb(publicDivision, studentGroup.StudyProgram)
            });
        }
        public static StudentGroupEventsAttestationViewModel Build(StudentGroup studentGroup, PublicDivision publicDivision, StudyEventsTimeTableKindCode studyEventsTimeTableKindCode)
        {
            var language = CultureHelper.CurrentLanguage;
            var studyEventsTimeTableKind = TimeTableHelper.GetStudyEventsTimeTableKindForCode(
                studentGroup.Session,
                studyEventsTimeTableKindCode);

            return(new StudentGroupEventsAttestationViewModel
            {
                StudentGroupId = studentGroup.Id,
                StudentGroupDisplayName = GetStudentGroupDisplayName(studentGroup),
                TimeTableDisplayName = TimeTableHelper.GetStudentGroupTimeTableDisplayNameForCodeByLanguage(studyEventsTimeTableKindCode, language),
                StudyEventsMonths = StudyEventsViewModelHelper.GetStudyEventsMonthsViewModelsForTerm(studentGroup, studyEventsTimeTableKind, studyEventsTimeTableKindCode),
                Breadcrumb = GetBreadcrumb(publicDivision, studentGroup.StudyProgram),
                StudyEventsTimeTableKindCode = studyEventsTimeTableKindCode
            });
        }
Example #14
0
 public static StudyProgramLevelViewModel Build(string studyLevelName, IEnumerable <StudyProgramNameLevelCombination> studyProgramCombinations, PublicDivision publicDivision)
 {
     return(new StudyProgramLevelViewModel
     {
         StudyLevelName = CapitalizeFirstLetter(studyLevelName),
         StudyProgramCombinations = studyProgramCombinations
                                    .Select(x => StudyProgramCombinationViewModel.Build(x, publicDivision))
                                    .OrderBy(sp => sp.Name)
     });
 }
Example #15
0
        public static StudyProgramShowViewModel Build(IEnumerable <StudyProgram> studyPrograms, PublicDivision publicDivision)
        {
            var firstStudyProgram = studyPrograms.First();
            var session           = firstStudyProgram.Session;

            var admissionYear = firstStudyProgram.AdmissionYear;
            var language      = CultureHelper.CurrentLanguage;

            var currentStudyYear  = StudyYearHelper.GetDefaultCurrentStudyYear(session);
            var previousStudyYear = StudyYearHelper.GetPreviousStudyYear(session);
            var studentGroups     = GetStudentGroups(studyPrograms);
            var studentGroupsForCurrentStudyYear  = studentGroups.Where(sg => sg.CurrentStudyYear == currentStudyYear);
            var studentGroupsForPreviousStudyYear = previousStudyYear.IsWebAvailable ? studentGroups.Where(sg => sg.CurrentStudyYear == previousStudyYear) : new List <StudentGroup>();

            return(new StudyProgramShowViewModel
            {
                StudyProgramDisplayText = GetStudyProgramDisplayText(firstStudyProgram),
                AdmissionYearText = GetAdmissionYearText(admissionYear),
                StudentGroupsForCurrentStudyYear = studentGroupsForCurrentStudyYear.Select(sg => StudentGroupItemViewModel.Build(sg, publicDivision)),
                StudentGroupsForPreviousStudyYear = studentGroupsForPreviousStudyYear.Select(sg => StudentGroupItemViewModel.Build(sg, publicDivision)),
                CurrentStudyYearDisplayText = currentStudyYear.GetDisplayNameByLanguage(language),
                PreviousStudyYearDisplayText = previousStudyYear.GetDisplayNameByLanguage(language),
                PublicDivisionAlias = publicDivision.Alias,
                Breadcrumb = new Breadcrumb()
                {
                    BreadcrumbHelper.GetBreadcrumbRootItem(false),
                    BreadcrumbHelper.GetBreadcrumbPublicDivisionItem(publicDivision, false),
                    BreadcrumbHelper.GetBreadcrumbCourseItem(publicDivision, firstStudyProgram, true),
                }
            });
        }