コード例 #1
0
        private void Edit_Click(object sender, RoutedEventArgs e)
        {
            // Get Id
            string IdString =
                ((TextBlock)
                 ((Grid)
                  ((StackPanel)
                   ((Border)
                    ((Button)sender).Parent).Parent).Parent).Children[0]).Text;

            int id = int.Parse(IdString);

            // Get episode
            ShowBindingModel model = controller.GetShow(id);

            // Edit info
            ChangeShow editWindow = new ChangeShow(model);

            editWindow.ShowDialog();

            if (editWindow.DialogResult == true)
            {
                if (!controller.EditShow(id, model))
                {
                    MessageBox.Show("There was a problem. The show was not edited");
                }
            }
        }
コード例 #2
0
 public void UpdateData(ShowBindingModel model)
 {
     this.Title          = model.Name;
     this.CurrentEpisode = model.CurrentEpisode;
     this.CurrentSeason  = model.CurrentSeason;
     this.Status         = model.Status;
 }
コード例 #3
0
        public EditShow(ShowBindingModel show)
        {
            InitializeComponent();

            this.showBM      = show;
            this.DataContext = this.showBM;
        }
コード例 #4
0
        public AddShow()
        {
            InitializeComponent();

            showBM           = new ShowBindingModel();
            this.DataContext = showBM;
        }
コード例 #5
0
        private void NewCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            ChangeShow addWindow = new ChangeShow();

            addWindow.ShowDialog();

            if (addWindow.DialogResult == true)
            {
                ShowBindingModel newShow = addWindow.NewShowInfo;

                try
                {
                    if (!currentController.AddShow(newShow))
                    {
                        MessageBox.Show("The show was not added. Check your internet conection ot the spelling of the show's title");
                    }
                }
                catch (HttpRequestException ex)
                {
                    if (ex.HResult == 401)
                    {
                        MessageBox.Show("The api token is expired");
                    }
                    if (ex.HResult == 404)
                    {
                        MessageBox.Show("The show was not found. Check your spelling of the name.");
                    }
                }
            }
        }
コード例 #6
0
        public override bool EditShow(int id, ShowBindingModel show)
        {
            BaseViewModel toBeChanged = views.FirstOrDefault(v => v.Id == id);
            BingeShow     chosen      = tvShows.FirstOrDefault(s => s.Id == id);

            if (toBeChanged != null)
            {
                views.Remove(toBeChanged);

                chosen.UpdateData(show);
                Thread save = new Thread(SaveShows);
                save.Start();

                toBeChanged = new BingeViewModel(chosen);

                if (BingeEnd(toBeChanged, chosen))
                {
                    return(false);
                }

                return(true);
            }

            return(false);
        }
コード例 #7
0
        public override bool AddShow(ShowBindingModel show)
        {
            string urlPath = String.Format(Constants.GetSearch, GetSlug(show.Name));

            SearchInfoRoot data = WebParser <SearchInfoRoot> .GetInfo(urlPath);

            BingeShow newShow = new BingeShow()
            {
                Id             = data.data[0].id,
                Title          = data.data[0].seriesName,
                CurrentEpisode = show.CurrentEpisode,
                CurrentSeason  = show.CurrentSeason,
            };

            BingeViewModel newView = new BingeViewModel(newShow);

            if (BingeEnd(newView, newShow))
            {
                return(false);
            }

            Thread save = new Thread(AddAndSave);

            save.Start(newShow);

            views.Add(newView);

            return(true);
        }
コード例 #8
0
        public bool EditShow(int id, ShowBindingModel show)
        {
            ShowViewModel toBeChanged = views.FirstOrDefault(v => v.Id == id);
            Show          chosen      = tvShows.FirstOrDefault(s => s.Id == id);

            if (toBeChanged != null)
            {
                views.Remove(toBeChanged);

                chosen.UpdateData(show);
                Thread save = new Thread(SaveShows);
                save.Start();

                toBeChanged = new ShowViewModel(chosen);
                if (!AddEpisodeInfo(toBeChanged))
                {
                    if (!IsOngoing(chosen))
                    {
                        return(false);
                    }
                }

                HelperFunctions.PutInTheRightPlace <ShowViewModel>(views, toBeChanged);

                return(true);
            }

            return(false);
        }
コード例 #9
0
        public bool AddShow(ShowBindingModel show)
        {
            string urlPath = String.Format(Constants.GetSearch, GetSlug(show.Name));

            SearchInfoRoot data = WebParser <SearchInfoRoot> .GetInfo(urlPath);

            Show newShow = new Show()
            {
                Id             = data.data[0].id,
                Title          = data.data[0].seriesName,
                CurrentEpisode = show.CurrentEpisode,
                CurrentSeason  = show.CurrentSeason,
                Status         = show.Status
            };

            ShowViewModel newView = new ShowViewModel(newShow);

            if (!AddEpisodeInfo(newView))
            {
                if (data.data[0].status != "Continuing")
                {
                    return(false);
                }
            }

            Thread save = new Thread(AddAndSave);

            save.Start(newShow);

            //Insert the view into the collection
            HelperFunctions.PutInTheRightPlace <ShowViewModel>(views, newView);

            return(true);
        }
コード例 #10
0
        public override ShowBindingModel GetShow(int id)
        {
            BingeShow chosen = tvShows.FirstOrDefault(e => e.Id == id);

            ShowBindingModel model = new ShowBindingModel()
            {
                Name           = chosen.Title,
                CurrentEpisode = chosen.CurrentEpisode,
                CurrentSeason  = chosen.CurrentSeason
            };

            return(model);
        }
コード例 #11
0
 public abstract bool EditShow(int id, ShowBindingModel show);
コード例 #12
0
 public abstract bool AddShow(ShowBindingModel show);