Beispiel #1
0
 public static EducatorEventsIndexViewModel Build(Session session, string educatorLastNameQuery)
 {
     return(new EducatorEventsIndexViewModel
     {
         EducatorLastNameQuery = educatorLastNameQuery,
         Educators = EducatorEventsHelper.SearchEducatorsByLastName(session, educatorLastNameQuery),
         Breadcrumb = new Breadcrumb()
         {
             BreadcrumbHelper.GetBreadcrumbRootItem(false),
             BreadcrumbHelper.GetBreadcrumbEducatorsItem(true),
         }
     });
 }
        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 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,
                    }
                }
            });
        }