public override bool NextEpisode(int id) { BaseViewModel toBeChanged = views.FirstOrDefault(v => v.Id == id); BingeShow chosen = tvShows.FirstOrDefault(s => s.Id == id); if (chosen != null) { chosen.CurrentEpisode++; toBeChanged.CurrentEpisode++; if (!AddEpisodeInfo(toBeChanged)) { chosen.CurrentEpisode = 1; chosen.CurrentSeason++; toBeChanged.CurrentEpisode = 1; toBeChanged.CurrentSeason++; if (BingeEnd(toBeChanged, chosen)) { return(false); } } return(true); } return(false); }
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); }
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); }
private void PermanentlyRemove(object param) { int id = (int)param; BingeShow toBeRemoved = tvShows.FirstOrDefault(s => s.Id == id); tvShows.Remove(toBeRemoved); SaveShows(); }
public BingeViewModel(BingeShow show) { this.Id = show.Id; this.Title = show.Title; this.CurrentEpisode = show.CurrentEpisode; this.CurrentSeason = show.CurrentSeason; this.PosterSource = HelperFunctions.GetPosterSorce(show.Id, show.CurrentSeason); }
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); }
private void MoveToFollow(BingeShow show) { Show newShow = new Show() { Id = show.Id, CurrentEpisode = show.CurrentEpisode, CurrentSeason = show.CurrentSeason, Title = show.Title, Status = Status.Green }; List <Show> followed = JSONParser <List <Show> > .ReadFile(Constants.FollowedFile); followed.Add(newShow); JSONParser <List <Show> > .WriteJson(followed, Constants.FollowedFile); }
private bool IsOngoing(BingeShow chosen) { string path = String.Format(Constants.GetSeries, chosen.Id); try { ShowInfoRoot data = WebParser <ShowInfoRoot> .GetInfo(path); if (data.data.status == "Continuing") { return(true); } } catch (Exception) { //Unautorized return(false); } return(false); }
private bool BingeEnd(BaseViewModel model, BingeShow show) { if (!AddEpisodeInfo(model)) { if (IsOngoing(show)) { MoveToFollow(show); Thread remove = new Thread(PermanentlyRemove); remove.Start(show.Id); } else { Thread remove = new Thread(PermanentlyRemove); remove.Start(show.Id); } return(true); } return(false); }