Ejemplo n.º 1
0
        public static EducatorEventsShowModel Build(EducatorMasterPerson educatorMasterPerson, DateTime?weekMonday)
        {
            LanguageCode language  = CultureHelper.CurrentLanguage;
            DateTime     weekStart = weekMonday.HasValue
                ? weekMonday.Value.AddDays(1 - (int)weekMonday.Value.DayOfWeek).Date
                : DateTime.Now.AddDays(1 - (int)DateTime.Now.DayOfWeek).Date;
            DateTime weekEnd                 = weekStart.AddDays(7);
            string   educatorDisplayText     = educatorMasterPerson.GetDisplayNameByLanguage(language);
            string   educatorFullDisplayText = educatorMasterPerson.GetLongDisplayNameByLanguage(language);

            return(new EducatorEventsShowModel
            {
                EducatorDisplayText = educatorDisplayText,
                EducatorFullDisplayText = educatorFullDisplayText,
                Title = $"{Resources.Resources.TimetableForEducator} {educatorFullDisplayText}",
                EducatorMasterId = educatorMasterPerson.Id,
                EducatorEventsDays = StudyEventsViewModelHelper.GetEducatorEventsDayModels(educatorMasterPerson, weekStart, weekEnd),
                PreviousWeekMonday = weekStart.AddDays(-7).ToString("yyyy-MM-dd"),
                WeekStart = weekStart,
                WeekMonday = weekStart.ToString("yyyy-MM-dd"),
                NextWeekMonday = weekStart.AddDays(7).ToString("yyyy-MM-dd"),
                WeekDisplayText = $"{weekStart:d MMMM} – {weekEnd.AddDays(-1):d MMMM}",
                IsCurrentWeekReferenceAvailable = weekStart != DateTime.Now.AddDays(1 - (int)DateTime.Now.DayOfWeek).Date,
            });
        }
        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()),
            });
        }
        internal static StudentGroupEventsWeekModel Build(StudentGroup studentGroup, DateTime from, DateTime to)
        {
            var days = StudyEventsViewModelHelper.GetStudyEventsDaysViewModelsForDateRange(studentGroup, null, from, to).ToList();

            return(new StudentGroupEventsWeekModel
            {
                StudentGroupId = studentGroup.Id,
                StudentGroupDisplayName = studentGroup.Name,
                TimeTableDisplayName = TimeTableHelper.GetStudentGroupTimeTableDisplayNameForCodeByLanguage(StudyEventsTimeTableKindCode.Primary, CultureHelper.CurrentLanguage),
                Days = days,
                DurationDisplayText = $"{from:d MMMM yyyy} - {to:d MMMM yyyy}",
                HasEvents = days.Any(seadivm => seadivm.DayStudyEvents.Any()),
            });
        }
        public static EducatorEventsShowAllViewModel Build(EducatorMasterPerson educatorMasterPerson, int?next)
        {
            bool         showNext                = next.HasValue && next.Value > 0;
            LanguageCode language                = CultureHelper.CurrentLanguage;
            string       educatorDisplayText     = educatorMasterPerson.GetDisplayNameByLanguage(language);
            string       educatorLongDisplayText = educatorMasterPerson.GetLongDisplayNameByLanguage(language);
            DateTime     summerTermBoundary      = new DateTime(DateTime.Now.Month == 1 ? DateTime.Now.Year - 1 : DateTime.Now.Year, 8, 1);
            DateTime     winterTermBoundary      = new DateTime(DateTime.Now >= summerTermBoundary && DateTime.Now.Month > 1 ? DateTime.Now.Year + 1 : DateTime.Now.Year, 2, 1);
            DateTime     nextSummerTermBoundary  = new DateTime(summerTermBoundary.Year + 1, summerTermBoundary.Month, summerTermBoundary.Day);
            DateTime     nextWinterTermBoundary  = new DateTime(winterTermBoundary.Year + 1, winterTermBoundary.Month, winterTermBoundary.Day);
            bool         isSpringTerm            = winterTermBoundary < DateTime.Now && DateTime.Now < summerTermBoundary;
            DateTime     fromDate                = showNext
                ? (isSpringTerm ? summerTermBoundary : winterTermBoundary)
                : (isSpringTerm ? winterTermBoundary : summerTermBoundary);
            DateTime toDate = showNext
                ? (isSpringTerm ? nextWinterTermBoundary : nextSummerTermBoundary)
                : (isSpringTerm ? summerTermBoundary : winterTermBoundary);
            string title = string.Format("{0} {1}", Resources.Resources.TimetableForEducator,
                                         educatorLongDisplayText);
            IEnumerable <StudyEventAggregatedDayItemViewModel> educatorEventsDays = StudyEventsViewModelHelper.GetEducatorAggregatedEventsDays(educatorMasterPerson, fromDate, toDate);

            return(new EducatorEventsShowAllViewModel
            {
                Next = next,
                From = fromDate,
                To = toDate,
                EducatorDisplayText = educatorDisplayText,
                EducatorLongDisplayText = educatorLongDisplayText,
                DateRangeDisplayText = string.Format("{0:d MMMM yyyy} - {1:d MMMM yyyy}", fromDate, toDate),
                Title = title,
                EducatorMasterId = educatorMasterPerson.Id,
                EducatorEventsDays = educatorEventsDays,
                IsSpringTerm = isSpringTerm,
                SpringTermLinkAvailable = isSpringTerm == showNext,
                AutumnTermLinkAvailable = isSpringTerm != showNext,
                HasEvents = educatorEventsDays.Any(seadivm => seadivm.DayStudyEvents.Any()),
                Breadcrumb = new Breadcrumb()
                {
                    BreadcrumbHelper.GetBreadcrumbRootItem(false),
                    BreadcrumbHelper.GetBreadcrumbEducatorsItem(false),
                    new BreadcrumbItem
                    {
                        IsActive = true,
                        DisplayText = educatorDisplayText,
                    }
                }
            });
        }
        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
            });
        }
        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 EducatorEventsShowViewModel Build(EducatorMasterPerson educatorMasterPerson, DateTime?weekMonday)
        {
            LanguageCode language  = CultureHelper.CurrentLanguage;
            DateTime     weekStart = weekMonday.HasValue
                ? weekMonday.Value.AddDays(1 - (int)weekMonday.Value.DayOfWeek).Date
                : DateTime.Now.AddDays(1 - (int)DateTime.Now.DayOfWeek).Date;
            DateTime weekEnd                 = weekStart.AddDays(7);
            string   educatorDisplayText     = educatorMasterPerson.GetDisplayNameByLanguage(language);
            string   educatorFullDisplayText = educatorMasterPerson.GetLongDisplayNameByLanguage(language);

            return(new EducatorEventsShowViewModel
            {
                EducatorDisplayText = educatorDisplayText,
                EducatorFullDisplayText = educatorFullDisplayText,
                Title = string.Format("{0} {1}", Resources.Resources.TimetableForEducator, educatorFullDisplayText),
                EducatorMasterId = educatorMasterPerson.Id,
                EducatorEventsDays = StudyEventsViewModelHelper.GetEducatorEventsDayViewModels(educatorMasterPerson, weekStart, weekEnd),
                PreviousWeekMonday = weekStart.AddDays(-7).ToString("yyyy-MM-dd"),
                WeekStart = weekStart,
                WeekMonday = weekStart.ToString("yyyy-MM-dd"),
                NextWeekMonday = weekStart.AddDays(7).ToString("yyyy-MM-dd"),
                WeekDisplayText = language == LanguageCode.English
                    ? string.Format("{0:d MMMM} – {1:d MMMM}", weekStart, weekEnd.AddDays(-1))
                    : string.Format("{0:d MMMM} – {1:d MMMM}", weekStart, weekEnd.AddDays(-1)),
                IsCurrentWeekReferenceAvailable = weekStart != DateTime.Now.AddDays(1 - (int)DateTime.Now.DayOfWeek).Date,
                Breadcrumb = new Breadcrumb()
                {
                    BreadcrumbHelper.GetBreadcrumbRootItem(false),
                    BreadcrumbHelper.GetBreadcrumbEducatorsItem(false),
                    new BreadcrumbItem
                    {
                        IsActive = true,
                        DisplayText = educatorDisplayText,
                    }
                }
            });
        }