public override async Task <bool> RemoveScheduleAsync(ISchedule schedule) { await _initComplete.Task; TvDatabase.Schedule tvSchedule = TvDatabase.Schedule.Retrieve(schedule.ScheduleId); // Already deleted somewhere else? if (tvSchedule == null) { return(true); } _tvControl.StopRecordingSchedule(tvSchedule.IdSchedule); // delete canceled schedules first foreach (var cs in CanceledSchedule.ListAll().Where(x => x.IdSchedule == tvSchedule.IdSchedule)) { cs.Remove(); } try { // can fail if "StopRecordingSchedule" already deleted the entry TvDatabase.Schedule.ResetProgramStates(tvSchedule.IdSchedule); tvSchedule.Remove(); } catch { } _tvControl.OnNewSchedule(); // I don't think this is needed, but doesn't hurt either return(true); }
public override bool RemoveSchedule(ISchedule schedule) { TvDatabase.Schedule tvSchedule = TvDatabase.Schedule.Retrieve(schedule.ScheduleId); // Already deleted somewhere else? if (tvSchedule == null) { return(true); } _tvControl.StopRecordingSchedule(tvSchedule.IdSchedule); // delete canceled schedules first foreach (var cs in CanceledSchedule.ListAll().Where(x => x.IdSchedule == tvSchedule.IdSchedule)) { cs.Remove(); } tvSchedule.Remove(); _tvControl.OnNewSchedule(); // I don't think this is needed, but doesn't hurt either return(true); }