示例#1
0
        public static DailyTriggerViewModel FromTrigger(IDailyTimeIntervalTrigger trigger)
        {
            var model = new DailyTriggerViewModel()
            {
                RepeatCount    = trigger.RepeatCount,
                RepeatInterval = trigger.RepeatInterval,
                RepeatUnit     = trigger.RepeatIntervalUnit,
                StartTime      = trigger.StartTimeOfDay.ToTimeSpan(),
                EndTime        = trigger.EndTimeOfDay.ToTimeSpan(),
                DaysOfWeek     = DaysOfWeekViewModel.Create(trigger.DaysOfWeek),
                TimeZone       = trigger.TimeZone.Id,
            };

            if (model.RepeatCount == -1)
            {
                model.RepeatCount   = null;
                model.RepeatForever = true;
            }

            return(model);
        }
示例#2
0
        public static DaysOfWeekViewModel Create(IEnumerable <DayOfWeek> list)
        {
            var model = new DaysOfWeekViewModel();

            foreach (var item in list)
            {
                if (item == DayOfWeek.Sunday)
                {
                    model.Sunday = true;
                }
                if (item == DayOfWeek.Monday)
                {
                    model.Monday = true;
                }
                if (item == DayOfWeek.Tuesday)
                {
                    model.Tuesday = true;
                }
                if (item == DayOfWeek.Wednesday)
                {
                    model.Wednesday = true;
                }
                if (item == DayOfWeek.Thursday)
                {
                    model.Thursday = true;
                }
                if (item == DayOfWeek.Friday)
                {
                    model.Friday = true;
                }
                if (item == DayOfWeek.Saturday)
                {
                    model.Saturday = true;
                }
            }
            return(model);
        }