Пример #1
0
        public ExamViewModel(Exam exam, WellknownData schedule)
        {
            ShortName = exam.ShortName;
            StartTime = exam.StartTime.LocalDateTime;
            EndTime   = exam.EndTime.LocalDateTime;
            Countdown = (int)(StartTime.GetLocalDate() - DateTimeOffset.Now.Date).TotalDays;
            EquivalentStartSession = FindEqivalentSession(StartTime.TimeOfDay, schedule);
            EquivalentEndSession   = FindEqivalentSession(EndTime.TimeOfDay, schedule);
            Week          = exam.Week;
            DayOfWeek     = exam.DayOfWeek;
            ShortLocation = exam.ShortLocation;
            Seating       = exam.Seating;

            ILocalizationService locService = Application.Current.GetService <ILocalizationService>();

            TimeRangeDisplay = locService.Format("ScheduleSummaryTimeRangeFormat", StartTime.ToLocalTime().TimeOfDay, EndTime.ToLocalTime().TimeOfDay);
            if (Countdown < 0)
            {
                CountdownDisplay = locService.GetString("ScheduleSummaryExamCountdownEnded");
            }
            else if (Countdown < 3)
            {
                CountdownDisplay = locService.GetString($"ScheduleSummaryExamCountdown{Countdown}");
            }
            else
            {
                CountdownDisplay = locService.Format("ScheduleSummaryExamCountdownFormat", Countdown);
            }
        }