Exemple #1
0
        private async Task Startup()
        {
            try
            {
                LoadWindowSettings();
                SetupTrayIcon();
                SetupShortcuts();
                SetupNetChange();
                //SetupShowTimer();

                await Task.Delay(1000);

                await SetupTvdbAPI();
                await SetupStructure();
                await CheckForMissingLocalData();

                LoadSeries();

                MyViewModel.RefreshView();
                SortDataGrid(AppGlobal.Settings.DefaultSortColumn, AppGlobal.Settings.DefaultSortDirection);

                //if (await CheckForShowUpdates())
                //	MyViewModel.RefreshView();

                MyViewModel.ResetStatus();
            }
            catch (Exception ex)
            {
                ErrorMethods.LogError(ex.Message);
            }
        }
Exemple #2
0
        public SeriesResult <User> UserDelete()
        {
            try
            {
                connection.Open();

                cmd = CreateSqlCommandForSP("UserDelete");
                cmd.Parameters.AddWithValue("UserID", AppGlobal.User.UserID.ToString());
                cmd.ExecuteNonQuery();

                return(new SeriesResult <User> {
                    Result = SQLResult.Success
                });
            }
            catch (Exception ex)
            {
                ErrorMethods.LogError(ex.Message);

                return(new SeriesResult <User> {
                    Result = SQLResult.ErrorHasOccured, Message = ex.Message
                });
            }
            finally
            {
                connection.Close();
            }
        }
Exemple #3
0
        public SeriesResult <Category> UserShowCategoryAdd(int UserShowID, Category record)
        {
            try
            {
                connection.Open();

                cmd = CreateSqlCommandForSP("UserShowCategoryAdd");
                cmd.Parameters.AddWithValue("UserShowID", UserShowID);
                cmd.Parameters.AddWithValue("CategoryID", record.CategoryID);
                cmd.Parameters.Add("ID", SqlDbType.Int).Direction = ParameterDirection.Output;
                cmd.ExecuteNonQuery();

                record.UserShowCategoryID = int.Parse(cmd.Parameters["ID"].Value.ToString());

                return(new SeriesResult <Category> {
                    Result = SQLResult.Success, Data = record
                });
            }
            catch (Exception e)
            {
                ErrorMethods.LogError(e.Message);
                return(new SeriesResult <Category> {
                    Result = SQLResult.ErrorHasOccured, Message = e.Message
                });
            }
            finally
            {
                connection.Close();
            }
        }
        private void Btn_WatchEpisode_Click(object sender, RoutedEventArgs e)
        {
            bool found = false;

            try
            {
                if (string.IsNullOrEmpty(MyViewModel.MyShow.LocalSeriesPath))
                {
                    return;
                }
                if (!Directory.Exists(MyViewModel.MyShow.LocalSeriesPath))
                {
                    return;
                }

                Button m = (Button)sender;
                Panel  p = (m.Parent as Panel).Parent as Panel;

                int episodeNumber = int.Parse(p.Tag.ToString());

                string seasonPath = Path.Combine(MyViewModel.MyShow.LocalSeriesPath, "Season " + MyViewModel.ViewingSeason);
                var    dir        = new DirectoryInfo(seasonPath);

                if (!dir.Exists)
                {
                    return;
                }

                var files = dir.GetFiles();

                Episode episode = MyViewModel.MyShow.GetEpisode(MyViewModel.ViewingSeason, episodeNumber);
                foreach (FileInfo file in files)
                {
                    if (file.Name.Contains(episode.FullEpisodeString))
                    {
                        found = true;
                        var q = CommonMethods.StartProcess(file.FullName);
                        // Testing
                        //q.EnableRaisingEvents = true;
                        //q.Exited += delegate
                        //{
                        //	TimeSpan watchTime = DateTime.Now - q.StartTime;

                        //	MessageBox.Show("You watched for " + watchTime.TotalSeconds + " seconds");
                        //};

                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorMethods.LogError(ex.Message);
            }

            if (!found)
            {
                MessageBox.Show("Failed to locate episode on local drive.", "Episode not found");
            }
        }
        private async void Btn_EpisodeEyeToggle_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (busy)
                {
                    return;
                }

                busy = true;

                ToggleButton m = (ToggleButton)sender;
                Grid         p = m.Parent as Grid;

                m.IsHitTestVisible = false;

                int episode = int.Parse(p.Tag.ToString());
                await EpisodeWatchedToggle(episode);

                m.IsHitTestVisible = true;
                busy = false;
            }
            catch (Exception ex)
            {
                ErrorMethods.LogError(ex.Message);
            }
        }
Exemple #6
0
        public SeriesResult <Category> UserShowCategoryDelete(int UserShowCategoryID)
        {
            try
            {
                connection.Open();

                cmd = CreateSqlCommandForSP("UserShowCategoryDelete");
                cmd.Parameters.AddWithValue("UserShowCategoryID", UserShowCategoryID);
                cmd.ExecuteNonQuery();

                return(new SeriesResult <Category> {
                    Result = SQLResult.Success
                });
            }
            catch (Exception e)
            {
                ErrorMethods.LogError(e.Message);
                return(new SeriesResult <Category> {
                    Result = SQLResult.ErrorHasOccured, Message = e.Message
                });
            }
            finally
            {
                connection.Close();
            }
        }
Exemple #7
0
        public SeriesResult <Category> UserCategoryDeleteMutliple(List <Category> records)
        {
            try
            {
                connection.Open();

                cmd = CreateSqlCommandForSP("UserCategoryDelete");
                foreach (Category record in records)
                {
                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("UserID", AppGlobal.User.UserID);
                    cmd.Parameters.AddWithValue("CategoryID", record.CategoryID);
                    cmd.ExecuteNonQuery();
                }

                return(new SeriesResult <Category> {
                    Result = SQLResult.Success
                });
            }
            catch (Exception ex)
            {
                ErrorMethods.LogError(ex.Message);
                return(new SeriesResult <Category> {
                    Result = SQLResult.ErrorHasOccured, Message = ex.Message
                });
            }
            finally
            {
                connection.Close();
            }
        }
Exemple #8
0
        private async Task LoadBannerAsync()
        {
            try
            {
                Models.Image banner = MyViewModel.MyShow.Banners.First();
                if (!File.Exists(MyViewModel.MyShow.LocalBannerPath) && !File.Exists(banner.LocalImagePath))
                {
                    using (WebClient client = new WebClient())
                    {
                        await client.DownloadFileTaskAsync(new Uri(banner.OnlineImageUrl), banner.LocalImagePath);
                    }

                    if (File.Exists(MyViewModel.MyShow.LocalBannerPath))
                    {
                        File.Delete(MyViewModel.MyShow.LocalBannerPath);
                    }

                    File.Copy(banner.LocalImagePath, MyViewModel.MyShow.LocalBannerPath);

                    MyViewModel.RefreshBanner();
                }
            }
            catch (Exception ex)
            {
                ErrorMethods.LogError(ex.Message);
            }
        }
Exemple #9
0
        private async Task SetupStructure()
        {
            MyViewModel.SetStatus("Setting up Structure");

            try
            {
                // Check local series folder directory
                if (!string.IsNullOrEmpty(AppGlobal.Paths.LocalSeriesDirectory) && !Directory.Exists(AppGlobal.Paths.LocalSeriesDirectory))
                {
                    MessageBox.Show($"Series path '{AppGlobal.Paths.LocalSeriesDirectory}' does not exist or cannot be read. Please set a new path.");

                    AppGlobal.Settings.LocalSeriesFolder = "";
                    AppGlobal.Settings.Save();
                }

                // Check for files
                if (!File.Exists(AppGlobal.Paths.EztvIDFile) || DateTime.Now > Properties.Settings.Default.EztvLastUpdate.AddDays(7))
                {
                    MyViewModel.SetStatus("Updating Eztv data");

                    await MethodCollection.UpdateEztvShowFileAsync();

                    Properties.Settings.Default.EztvLastUpdate = DateTime.Now;
                    Properties.Settings.Default.Save();
                }
            }
            catch (Exception ex)
            {
                ErrorMethods.LogError(ex.Message);
            }
        }
Exemple #10
0
        public SeriesResult <Show> UserShowUpdate(Show record)
        {
            try
            {
                connection.Open();

                cmd = CreateSqlCommandForSP("UserShowUpdate");
                cmd.Parameters.AddWithValue("UserID", AppGlobal.User.UserID);
                cmd.Parameters.AddWithValue("TvdbID", record.Id);
                int r = cmd.ExecuteNonQuery();

                return(new SeriesResult <Show> {
                    Result = SQLResult.Success
                });
            }
            catch (Exception e)
            {
                ErrorMethods.LogError(e.Message);
                return(new SeriesResult <Show> {
                    Result = SQLResult.ErrorHasOccured, Message = e.Message
                });
            }
            finally
            {
                connection.Close();
            }
        }
Exemple #11
0
        private async void CM_DownloadLastEpisode_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (MyViewModel.IsBusy)
                {
                    return;
                }

                Show show = view_DataGridView.SelectedItem as Show;

                MyViewModel.SetStatus($"Finding magnets for {show.SeriesName} {show.LatestEpisode.FullEpisodeString}");

                var torrents = await MethodCollection.GetEpisodeTorrentList(show, show.LatestEpisode);

                if (torrents == null || torrents.Count == 0)
                {
                    PopupNotification($"Failed to find last episode for {show.SeriesName}");
                    MyViewModel.ResetStatus();
                    return;
                }

                await DialogHost.Show(new EpisodeDownloadsDialog(torrents), "RootDialog");

                MyViewModel.ResetStatus();
            }
            catch (Exception ex)
            {
                ErrorMethods.LogError(ex.Message);
            }
        }
Exemple #12
0
        private async void CM_Delete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string text = "Are you sure you would like to delete " + view_DataGridView.SelectedItems.Count + " show" + (view_DataGridView.SelectedItems.Count == 1 ? "" : "s") + "?";

                if (MessageBox.Show(text, "Confirm deletion", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    List <Show> toDelete = view_DataGridView.SelectedItems.Cast <Show>().ToList();

                    foreach (Show show in toDelete)
                    {
                        SeriesResult <Show> result = await AppGlobal.Db.UserShowDeleteAsync(show.UserShowID);

                        if (result.Result == SQLResult.Success)
                        {
                            AppGlobal.User.Shows.Remove(show);

                            AppGlobal.Settings.RemoveSeriesPath(show.Id);
                            AppGlobal.Settings.Save();
                        }
                        else
                        {
                            MessageBox.Show("Something went wrong!\n\n" + result.Message);
                        }
                    }

                    MyViewModel.RefreshView();
                }
            }
            catch (Exception ex)
            {
                ErrorMethods.LogError(ex.Message);
            }
        }
Exemple #13
0
        public SeriesResult <UserShowWatch> UserShowWatchDelete(UserShowWatch record)
        {
            try
            {
                connection.Open();

                cmd = CreateSqlCommandForSP("UserShowWatchDelete");
                cmd.Parameters.AddWithValue("UserShowWatchID", record.ID);
                cmd.ExecuteNonQuery();

                return(new SeriesResult <UserShowWatch> {
                    Result = SQLResult.Success, Data = record
                });
            }
            catch (Exception e)
            {
                ErrorMethods.LogError(e.Message);

                return(new SeriesResult <UserShowWatch> {
                    Result = SQLResult.ErrorHasOccured, Message = e.Message
                });
            }
            finally
            {
                connection.Close();
            }
        }
Exemple #14
0
        public SeriesResult <Category> UserCategoryAddMultiple(List <Category> records)
        {
            try
            {
                connection.Open();

                cmd = CreateSqlCommandForSP("UserCategoryAdd");
                foreach (Category record in records)
                {
                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("UserID", AppGlobal.User.UserID);
                    cmd.Parameters.AddWithValue("Category", record.Name);
                    cmd.Parameters.Add("ID", SqlDbType.Int).Direction = ParameterDirection.Output;
                    cmd.ExecuteNonQuery();

                    record.CategoryID = int.Parse(cmd.Parameters["ID"].Value.ToString());
                }

                return(new SeriesResult <Category> {
                    Result = SQLResult.Success, ListData = records
                });
            }
            catch (Exception e)
            {
                ErrorMethods.LogError(e.Message);
                return(new SeriesResult <Category> {
                    Result = SQLResult.ErrorHasOccured, Message = e.Message
                });
            }
            finally
            {
                connection.Close();
            }
        }
Exemple #15
0
        private async Task CheckForMissingLocalData()
        {
            MyViewModel.SetStatus("Verifying local data");

            try
            {
                List <Show> missingShows = new List <Show>();
                foreach (Show show in AppGlobal.User.Shows)
                {
                    string tvdbPath = Path.Combine(AppGlobal.Paths.SeriesDirectory, show.Id.ToString());

                    if (!Directory.Exists(tvdbPath) || !File.Exists(show.LocalJsonPath))
                    {
                        missingShows.Add(show);
                    }
                }

                if (missingShows.Count > 0)
                {
                    int counter = 1;
                    foreach (Show show in missingShows)
                    {
                        MyViewModel.SetStatus($"Downloading data {counter++}/{missingShows.Count} - {show.SeriesName}");

                        await MethodCollection.RetrieveTvdbDataForSeriesAsync(show.Id);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorMethods.LogError(ex.Message);
            }
        }
Exemple #16
0
        public SeriesResult <User> UserUpdate(User UserData)
        {
            try
            {
                connection.Open();

                cmd = CreateSqlCommandForSP("UserUpdate");
                cmd.Parameters.AddWithValue("UserID", UserData.UserID);
                cmd.Parameters.AddWithValue("Name", UserData.FirstName);
                cmd.Parameters.AddWithValue("Surname", UserData.LastName);
                cmd.Parameters.AddWithValue("Password", sha256(UserData.Password));
                cmd.Parameters.AddWithValue("DoB", UserData.DateOfBirth);
                int r = cmd.ExecuteNonQuery();

                return(new SeriesResult <User> {
                    Result = SQLResult.Success
                });
            }
            catch (Exception e)
            {
                ErrorMethods.LogError(e.Message);
                return(new SeriesResult <User> {
                    Result = SQLResult.ErrorHasOccured, Message = e.Message
                });
            }
            finally
            {
                connection.Close();
            }
        }
Exemple #17
0
        private async void Btn_Search_Click(object sender, RoutedEventArgs e)
        {
            if (busySearching)
            {
                return;
            }

            string searchString = txt_Search.Text;

            if (string.IsNullOrWhiteSpace(searchString))
            {
                txt_Search.Focus();
                SystemSounds.Beep.Play();

                return;
            }

            try
            {
                busySearching = true;

                MyViewModel.SearchResults.Clear();
                btn_Accept.IsEnabled = false;

                MyViewModel.SetStatus("Searching...", Brushes.Yellow);

                string url = $"https://api.thetvdb.com/search/series?name={Uri.EscapeUriString(searchString)}";
                ReturnResult <TvdbAPI> jsonData = await Request.ExecuteAndDeserializeAsync <TvdbAPI>("GET", url);

                if (jsonData.Result.Error == null)
                {
                    List <Show> results = JsonConvert.DeserializeObject <List <Show> >(jsonData.Result.Data.ToString())
                                          .Where(x => !x.SeriesName.Contains("Series Not Permitted"))
                                          .ToList();
                    results.ForEach(s => s.SetupVariables());

                    // TODO FIX
                    //MyViewModel.SearchResults.AddRange(results.OrderByDescending(x => x.YearDisplay == "Unknown" ? "1" : x.YearDisplay).ThenBy(x => x.SeriesName));

                    MyViewModel.SetStatus($"{MyViewModel.SearchResults.Count} results found", Brushes.LimeGreen);
                }
                else
                {
                    txt_Search.Focus();
                    txt_Search.SelectAll();

                    MyViewModel.SetStatus("No results found", Brushes.Red);
                }

                SystemSounds.Beep.Play();

                busySearching = false;
            }
            catch (Exception ex)
            {
                ErrorMethods.LogError(ex.Message);
            }
        }
Exemple #18
0
        public LoginResult UserLogin(string UsernameOrEmail, string Password)
        {
            try
            {
                connection.Open();

                cmd = CreateSqlCommandForSP("UserLogin");
                cmd.Parameters.AddWithValue("Email", UsernameOrEmail);
                cmd.Parameters.AddWithValue("Password", sha256(Password));
                SqlDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    reader.Read();

                    DateTime?DoB = null;
                    if (!string.IsNullOrEmpty(reader["DateOfBirth"].ToString()))
                    {
                        DoB = DateTime.Parse(reader["DateOfBirth"].ToString());
                    }

                    User data = new User
                    {
                        UserID      = int.Parse(reader["UserID"].ToString()),
                        Username    = reader["Username"].ToString(),
                        FirstName   = reader["Name"].ToString(),
                        LastName    = reader["Surname"].ToString(),
                        Email       = reader["Email"].ToString(),
                        Password    = Password,
                        DateOfBirth = DoB
                    };
                    reader.Close();

                    return(new LoginResult {
                        Result = SQLResult.LoginSuccessful, UserData = data
                    });
                }
                else
                {
                    return(new LoginResult {
                        Result = SQLResult.BadLogin
                    });
                }
            }
            catch (Exception ex)
            {
                ErrorMethods.LogError(ex.Message);
                return(new LoginResult {
                    Result = SQLResult.ErrorHasOccured, Message = ex.Message
                });
            }
            finally
            {
                connection.Close();
            }
        }
Exemple #19
0
 public static void DownloadImageToPath(string path, string url)
 {
     try
     {
         using (WebClient client = new WebClient())
             client.DownloadFile(url, path);
     }
     catch (Exception e)
     {
         ErrorMethods.LogError(e.Message);
     }
 }
Exemple #20
0
 public static void AppendToFile(string filePath, string text)
 {
     try
     {
         using (StreamWriter streamWriter = File.AppendText(filePath))
             streamWriter.WriteLine(text);
     }
     catch (Exception e)
     {
         ErrorMethods.LogError(e.Message);
     }
 }
Exemple #21
0
 public static void DownloadImageToPath(string dir, string imageName, string url)
 {
     try
     {
         using (WebClient client = new WebClient())
             client.DownloadFile(url, Path.Combine(dir, imageName));
     }
     catch (Exception e)
     {
         ErrorMethods.LogError(e.Message);
     }
 }
Exemple #22
0
        public SeriesResult <User> UserRegister(string Username, string Email, string Name, string Password)
        {
            try
            {
                connection.Open();

                cmd = CreateSqlCommandForSP("UserRegister");
                cmd.Parameters.AddWithValue("Username", Username);
                cmd.Parameters.AddWithValue("Email", Email);
                cmd.Parameters.AddWithValue("Name", Name);
                cmd.Parameters.AddWithValue("Password", sha256(Password));
                cmd.Parameters.Add("Result", SqlDbType.VarChar, 250).Direction = ParameterDirection.Output;
                cmd.ExecuteNonQuery();

                if (cmd.Parameters["Result"].Value.ToString() == "Registered")
                {
                    return(new SeriesResult <User> {
                        Result = SQLResult.RegistrationSuccessful, Message = "Registered"
                    });
                }
                else if (cmd.Parameters["Result"].Value.ToString() == "UsernameTaken")
                {
                    return(new SeriesResult <User> {
                        Result = SQLResult.UsernameAlreadyRegistered, Message = "Username already in use"
                    });
                }
                else if (cmd.Parameters["Result"].Value.ToString() == "EmailTaken")
                {
                    return(new SeriesResult <User> {
                        Result = SQLResult.EmailAlreadyRegistered, Message = "Email already registered"
                    });
                }
                else
                {
                    return(new SeriesResult <User> {
                        Result = SQLResult.ErrorHasOccured, Message = "No Message"
                    });
                }
            }
            catch (Exception e)
            {
                ErrorMethods.LogError(e.Message);
                return(new SeriesResult <User> {
                    Result = SQLResult.ErrorHasOccured, Message = e.Message
                });
            }
            finally
            {
                connection.Close();
            }
        }
        private void Btn_TreeViewToggle_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                treeViewOpen = !treeViewOpen;

                btn_TreeViewToggle.Content = treeViewOpen ? "Collapse" : "Expand";
                SeasonTreeView.Width       = new GridLength(treeViewOpen ? 300 : 150);
            }
            catch (Exception ex)
            {
                ErrorMethods.LogError(ex.Message);
            }
        }
Exemple #24
0
 private void CM_OpenIMDB_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         List <Show> selected = view_DataGridView.SelectedItems.Cast <Show>().ToList();
         foreach (Show sel in selected)
         {
             CommonMethods.StartProcess(sel.GetIMDbLink());
         }
     }
     catch (Exception ex)
     {
         ErrorMethods.LogError(ex.Message);
     }
 }
Exemple #25
0
        public static DateTime GetDateTime(string date)
        {
            DateTime dt = new DateTime();

            try
            {
                dt = DateTime.Parse(date, new CultureInfo("fr-FR", true), DateTimeStyles.AssumeLocal);
            }
            catch (Exception e)
            {
                ErrorMethods.LogError(e.Message);
            }

            return(dt);
        }
        private async Task RefreshEpisodeView()
        {
            Console.WriteLine(DateTime.Now.TimeOfDay);

            // TODO this causes some lag while it updates via MVVM
            MyViewModel.Episodes = MyViewModel.MyShow.GetEpisodesBySeason(MyViewModel.ViewingSeason);

            foreach (Episode episode in MyViewModel.Episodes)
            {
                if (cancel)
                {
                    break;
                }

                FileInfo fi = new FileInfo(episode.LocalImagePath);

                if (!fi.Exists || fi.Length == 0)
                {
                    try
                    {
                        using (WebClient client = new WebClient())
                        {
                            // TODO disable imagine loading for now
                            //await client.DownloadFileTaskAsync(new Uri(episode.OnlineImageUrl), episode.LocalImagePath);

                            episode.ImageText = "Done";
                        }
                    }
                    catch (WebException ex)
                    {
                        if (((HttpWebResponse)ex.Response).StatusCode == HttpStatusCode.NotFound)
                        {
                            File.Delete(episode.LocalImagePath);
                        }

                        episode.ImageText = "Not Available";
                    }
                    catch (Exception ex)
                    {
                        ErrorMethods.LogError(ex.Message);
                    }
                }

                episode.RefreshImage();
            }

            Console.WriteLine(DateTime.Now.TimeOfDay);
        }
Exemple #27
0
        private void CM_OpenFolder_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                List <Show> selected = view_DataGridView.SelectedItems.Cast <Show>().ToList();

                foreach (Show show in selected)
                {
                    OpenSeriesFolder(show);
                }
            }
            catch (Exception ex)
            {
                ErrorMethods.LogError(ex.Message);
            }
        }
        private async void Btn_Download_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Button m = (Button)sender;
                Panel  p = (m.Parent as Panel).Parent as Panel;

                int     episodeNumber = int.Parse(p.Tag.ToString());
                Episode episode       = MyViewModel.MyShow.GetEpisode(MyViewModel.ViewingSeason, episodeNumber);

                await MethodCollection.DownloadEpisode(MyViewModel.MyShow, episode);
            }
            catch (Exception ex)
            {
                ErrorMethods.LogError(ex.Message);
            }
        }
Exemple #29
0
        private void SortDataGrid(DataGridColumn column, ListSortDirection?direction = null)
        {
            try
            {
                if (direction == null)
                {
                    direction = (column.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending;
                }
                column.SortDirection = direction;

                ListCollectionView lcv = (ListCollectionView)MyViewModel.Collection.View;
                lcv.CustomSort = new DefaultComparer(column.Header.ToString(), (ListSortDirection)direction);
            }
            catch (Exception ex)
            {
                ErrorMethods.LogError(ex.Message);
            }
        }
Exemple #30
0
        public SeriesResult <UserShowWatch> UserShowWatchList(Show record)
        {
            try
            {
                connection.Open();

                cmd = CreateSqlCommandForSP("UserShowWatchList");
                cmd.Parameters.AddWithValue("UserShowID", record.UserShowID);
                reader = cmd.ExecuteReader();

                List <UserShowWatch> data = new List <UserShowWatch>();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        data.Add(new UserShowWatch
                        {
                            ID         = int.Parse(reader["UserShowWatchID"].ToString()),
                            UserShowID = int.Parse(reader["UserShowID"].ToString()),
                            SeasonNo   = int.Parse(reader["SeasonNo"].ToString()),
                            EpisodeNo  = int.Parse(reader["EpisodeNo"].ToString())
                        });
                    }
                }
                reader.Close();

                return(new SeriesResult <UserShowWatch> {
                    Result = SQLResult.Success, ListData = data
                });
            }
            catch (Exception e)
            {
                ErrorMethods.LogError(e.Message);
                return(new SeriesResult <UserShowWatch> {
                    Result = SQLResult.ErrorHasOccured, Message = e.Message
                });
            }
            finally
            {
                connection.Close();
            }
        }