protected virtual async Task <RecordingStatus?> CreateSchedule(IProgram program, ScheduleRecordingType recordingType = ScheduleRecordingType.Once)
        {
            IScheduleControlAsync scheduleControl = _tvHandler.ScheduleControl;
            RecordingStatus?      newStatus       = null;

            if (scheduleControl != null)
            {
                RecordingStatus?recordingStatus = await GetRecordingStatusAsync(program);

                if (recordingStatus.HasValue && (recordingStatus.Value.HasFlag(RecordingStatus.Scheduled) || recordingStatus.Value.HasFlag(RecordingStatus.SeriesScheduled)))
                {
                    // Delete any existing schedule
                    if (await scheduleControl.RemoveScheduleForProgramAsync(program, recordingStatus.Value.HasFlag(RecordingStatus.SeriesScheduled) ? ScheduleRecordingType.EveryTimeOnEveryChannel : ScheduleRecordingType.Once))
                    {
                        newStatus = RecordingStatus.None;
                    }
                }
                // Now create new schedule
                var result = await scheduleControl.CreateScheduleAsync(program, recordingType);

                if (result.Success)
                {
                    newStatus = recordingType == ScheduleRecordingType.Once ? RecordingStatus.Scheduled : RecordingStatus.SeriesScheduled;
                    UpdateRecordingStatus(program, (RecordingStatus)newStatus, recordingType);
                    SlimTvClientMessaging.SendSlimTvProgramChangedMessage(program);
                }
            }
            return(newStatus);
        }
 private void NotifyAllPrograms()
 {
     // Send message to all listeners that programs might have been changed
     foreach (IProgram program in _programs)
     {
         SlimTvClientMessaging.SendSlimTvProgramChangedMessage(program);
     }
 }
        protected virtual bool UpdateRecordingStatus(IProgram program, RecordingStatus newStatus)
        {
            IProgramRecordingStatus status = program as IProgramRecordingStatus;

            if (status == null)
            {
                return(false);
            }

            status.RecordingStatus = newStatus;
            SlimTvClientMessaging.SendSlimTvProgramChangedMessage(program);
            return(true);
        }