Exemple #1
0
        void btnTvDBLinkAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // get the current tvdb link
                VM_AnimeEpisode_User ep = DataContext as VM_AnimeEpisode_User;
                ep.RefreshAnime();
                if (ep.AniDB_Anime == null || ep.AniDB_Anime.TvSummary == null || ep.AniDB_Anime.TvSummary.CrossRefTvDBV2 == null ||
                    ep.AniDB_Anime.TvSummary.CrossRefTvDBV2.Count == 0)
                {
                    Utils.ShowErrorMessage(Shoko.Commons.Properties.Resources.EpisodeDetail_TvDBLink);
                    return;
                }

                Window wdw = Window.GetWindow(this);

                Cursor = Cursors.Wait;
                SelectTvDBEpisodeForm frm = new SelectTvDBEpisodeForm();
                frm.Owner = wdw;
                frm.Init(ep, ep.AniDB_Anime);
                bool?result = frm.ShowDialog();
                if (result.Value)
                {
                    // update info
                    CL_AnimeEpisode_User contract = VM_ShokoServer.Instance.ShokoServices.GetEpisode(
                        ep.AnimeEpisodeID, VM_ShokoServer.Instance.CurrentUser.JMMUserID);
                    if (contract != null)
                    {
                        ep.RefreshAnime(true);
                        ep.Populate(contract);
                        ep.SetTvDBInfo();
                    }
                }

                Cursor = Cursors.Arrow;
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Exemple #2
0
        void btnTvDBLinkRemove_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // get the current tvdb link
                VM_AnimeEpisode_User ep = DataContext as VM_AnimeEpisode_User;

                Window wdw = Window.GetWindow(this);

                Cursor = Cursors.Wait;

                string res = VM_ShokoServer.Instance.ShokoServices.RemoveLinkAniDBTvDBEpisode(ep.AniDB_EpisodeID);
                if (res.Length > 0)
                {
                    Cursor = Cursors.Arrow;
                    Utils.ShowErrorMessage(res);
                    return;
                }

                // update info
                VM_AnimeEpisode_User contract = (VM_AnimeEpisode_User)VM_ShokoServer.Instance.ShokoServices.GetEpisode(
                    ep.AnimeEpisodeID, VM_ShokoServer.Instance.CurrentUser.JMMUserID);
                if (contract != null)
                {
                    ep.RefreshAnime(true);
                    ep.Populate(contract);
                    ep.SetTvDBInfo();
                }


                Cursor = Cursors.Arrow;
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }