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; }
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; }
partial void UpdateSchedule(Schedule instance);
partial void DeleteSchedule(Schedule instance);
partial void InsertSchedule(Schedule instance);