예제 #1
0
        private Schedule ConvertScheduleClassToDbSchedule(ScheduleClass schedule)
        {
            var dbSchedule = new Schedule
            {
                Title = schedule.Name,
                ObjectId = schedule.Id,
                OverrideController = schedule.OverrideController,
                DeleteOnSync = schedule.DeleteOnSync
            };

            foreach (var controlledObject in schedule.ControlledObjects)
            {
                dbSchedule.SchedulesControlledProperties.Add(new SchedulesControlledProperty() { });
            }

            for (int index = 0; index < schedule.Days.Length; index++)
            {
                var day = schedule.Days[index];
                dbSchedule.SchedulesContents.AddRange(
                    day.Select(s => new SchedulesContent { Day = index, Time = s.Start, Value = s.Value }).ToList());
            }
            return dbSchedule;
        }
예제 #2
0
        private ScheduleClass ConvertDbScheduleToScheduleClass(Schedule dbSchedule)
        {
            var schedule = new ScheduleClass
            {
                Name = dbSchedule.Title,
                Id = dbSchedule.ObjectId,
                OverrideController = dbSchedule.OverrideController ?? false,
                DeleteOnSync = dbSchedule.DeleteOnSync ?? false,
                ControlledObjects = dbSchedule.SchedulesControlledProperties.Select(c => c.Property).ToList()
            };

            var days = new List<List<ValueTimeRange>>();
            for (var i = 0; i < 7; i++)
            {
                var daySchedule = dbSchedule.SchedulesContents.Where(sc => sc.Day == i).
                    Select(ds => new ValueTimeRange(ds.Time, ds.Value)).ToList();
                days.Add(daySchedule);
            }
            schedule.Days = days.ToArray();
            return schedule;
        }
예제 #3
0
 partial void UpdateSchedule(Schedule instance);
예제 #4
0
 partial void DeleteSchedule(Schedule instance);
예제 #5
0
 partial void InsertSchedule(Schedule instance);