private Shows PopulateShows() { Movies movies = new Movies(); Shows shows = new Shows(); movies.Add("Noc żywych prowadzących", Convert.ToDateTime("1996-12-12"), 125, "Roman R.", 17, "Matematyczny"); movies.Add("Dogłębna analiza", Convert.ToDateTime("2012-11-26"), 125, "Pedro", 19, "Polski"); shows.Add(Convert.ToDateTime("2017-12-12 12:00"), 120, 15, movies.Items[1]); shows.Add(Convert.ToDateTime("2017-12-12 17:00"), 120, 15, movies.Items[1]); shows.Add(Convert.ToDateTime("2017-12-12 8:00"), 120, 15, movies.Items[2]); return(shows); //shows.Items[1].AddReservation(new PersonalData("Bogdan", "Bobek", "123456789"), // new Tuple<int, int>(5, 6)); //shows.Items[1].AddReservation(new PersonalData("Zenon", "Ziemniak", "321654987"), // new Tuple<int, int>(5, 7)); //shows.Items[1].AddReservation(new PersonalData("Klaudiusz", "Kalafior", "321632387"), // new Tuple<int, int>(3, 4)); //shows.Items[1].AddReservation(new PersonalData("Piotr", "Pyra", "321365987"), // new Tuple<int, int>(3, 5)); //shows.Items[1].AddReservation(new PersonalData("Bartek", "Brokół", "854654987"), // new Tuple<int, int>(3, 6)); //shows.Items[2].AddReservation(new PersonalData("Bogdan", "Bobek", "123456789"), // new Tuple<int, int>(7, 6)); }
public void ShouldBeAbleToAddTwoDifferentShows() { Shows shows = new Shows(); shows.Add(CreateShowControl("My Title", "RSS", "GroupA")); shows.Add(CreateShowControl("My Title Other", "RSS Other", "GroupA")); shows.Count.Should().Be(2); }
public void ShouldNotAddAnotherShowWithSameRSSFeedOrTitle() { Shows shows = new Shows(); shows.Add(CreateShowControl("My Title", "RSS", "GroupA")); shows.Add(CreateShowControl("My Title", "RSS", "GroupA")); shows.Add(CreateShowControl("My Title Other", "RSS", "GroupA")); shows.Count.Should().Be(1); }
public void ShouldGroupsReturnCorrectGroups() { Shows shows = new Shows(); shows.Add(CreateShowControl("Show1", "RSS", "GroupA")); shows.Add(CreateShowControl("Show2", "RSSA", "GroupA")); shows.Add(CreateShowControl("Show3", "RSSB", "GroupB")); shows.Groups().Should().HaveCount(2); shows.Groups().Contains("GroupA").Should().BeTrue(); shows.Groups().Contains("GroupB").Should().BeTrue(); }
public void ShouldGetOnlyShowInNoGroup() { Shows shows = new Shows(); shows.Add(CreateShowControl("Show1", "RSSA", "None")); shows.Add(CreateShowControl("Show2", "RSSB", "None")); shows.Add(CreateShowControl("Show3", "RSSC", "None")); shows.Add(CreateShowControl("Show4", "RSSD")); List <ShowControl> showsInGroup = shows.ShowInGroup("Ungrouped"); showsInGroup.Should().HaveCount(4); }
public void ShouldGetOnlyShowInSameGroup() { Shows shows = new Shows(); shows.Add(CreateShowControl("Show1", "RSSA", "GroupA")); shows.Add(CreateShowControl("Show2", "RSSB", "GroupA")); shows.Add(CreateShowControl("Show3", "RSSC", "GroupB")); List <ShowControl> showsInGroup = shows.ShowInGroup("GroupA"); showsInGroup.Should().HaveCount(2); showsInGroup = shows.ShowInGroup("GroupB"); showsInGroup.Should().HaveCount(1); }
public async Task AddTvShow(VideoItem episode) { episode.IsTvShow = true; try { TvShow show = Shows.FirstOrDefault(x => x.ShowTitle == episode.ShowTitle); if (show == null) { // Generate a thumbnail for the show await Locator.MediaLibrary.FetchVideoThumbnailOrWaitAsync(episode); show = new TvShow(episode.ShowTitle); show.Episodes.Add(episode); Shows.Add(show); } else { if (show.Episodes.FirstOrDefault(x => x.Id == episode.Id) == null) { await DispatchHelper.InvokeAsync(CoreDispatcherPriority.Normal, () => show.Episodes.Add(episode)); } } } catch (Exception e) { LogHelper.Log(StringsHelper.ExceptionToString(e)); } }
public async Task LoadData() { LoadedPages++; var results = await Task.Run(() => TMDBService.Search(Query["query"], LoadedPages, 1)); foreach (var v in results.OnlyWithImages()) { Results.Add(v); if (v.media_type.Equals("movie")) { Movies.Add(v); } if (v.media_type.Equals("tv")) { Shows.Add(v); } if (v.media_type.Equals("person")) { People.Add(v); } } if (results.Count != 0) { LoadedMore(); } else { NoMore(); } }
static public void LoadShows(ShowsLoadCount loadCount) { Task.Run(() => { if (IsRun) { return; } IsRun = true; int count = (int)loadCount; var ids = ImdbIDs.GetRange(0, count); ImdbIDs.RemoveRange(0, count); foreach (var id in ids) { var show = GetShow(id); Shows.Add(show); var bitmap = GetBitmap(show.PosterLink); ShowsBitmaps.Add(bitmap); } IsRun = false; ShowsAdd?.Invoke(); }); }
public bool AddShow() { Show S1 = new Show(); Console.WriteLine("Enter Theatre Name: "); S1.TName = Console.ReadLine(); Console.WriteLine("Enter Movie Name: "); S1.MName = Console.ReadLine(); if (S1.MName != "" && S1.TName != "") { foreach (Movie m in Movies) { if (m.ThName == S1.TName && m.MovieName == S1.MName) { Console.WriteLine("Enter the Show Timing: "); S1.ShowName = Console.ReadLine(); Shows.Add(S1); Console.WriteLine(S1.ShowName + " show of " + S1.MName + " at " + S1.TName + " Theatre added."); return(true); } } Console.WriteLine(S1.MName + " Movie is not in " + S1.TName + " Theatre."); return(false); } else { Console.WriteLine("Theatre or Movie name cannot be null."); return(false); } }
public void ShouldAddShowToShowList() { Shows shows = new Shows(); shows.Add(CreateShowControl("My Title", "RSS", "GroupA")); shows.Count.Should().Be(1); }
static void AddShowImagesToCache(TmdbShowImages images) { if (images != null) { images.RequestAge = DateTime.Now.ToString(); Shows.Add(images); } }
public void AddShow(ShowTileViewModel show) { if (!Shows.Contains(show)) { Shows.Add(show); show.Show.PropertyChanged += Show_PropertyChanged; Setting.Sort(Shows); } }
public void AddShow(Show show) { if (HasAlreadyShow(show)) { return; } Shows?.Add(show); }
public async Task ForMe() { ShowFilters = "False"; Shows.Clear(); var shows = await _usersApi.GetItems <List <Model.Show> >(APIService.User.UserId, "RecommendedShows"); foreach (var show in shows) { Shows.Add(show); } }
public static Boolean AddFavoriteShow(Area show) { if (Shows.Any(s => s.ID == show.ID)) { return(false); } Shows.Add(show); Helpers.Settings.FavoriteShows = JsonConvert.SerializeObject(Shows); FavoritesDirty = true; return(true); }
private void GenerateShows() { Shows.Add(new Show { MediaId = Guid.Parse("387271A1-4009-4667-BC49-5053BBC8E841"), MediaName = "True Detective", PosterUri = "http://store.hbo.com/imgcache/product/resized/000/506/911/catl/true-detective-touch-darkness-poster-11x17_1000.jpg", Accolades = AwardStatus.Won, NumberOfSeasons = 2, DateOfRelease = DateTime.Parse("2014-01-12"), CreatedOn = DateTime.Now }); }
public bool AddShow(int id) { if (ShowsId.Any(s => s == id)) { return(false); } ShowsId.Add(id); var show = GetQueryResult <Show>($"http://api.tvmaze.com/shows/{id}"); show.Episodes = GetQueryResult <List <Episode> >($"http://api.tvmaze.com/shows/{id}/episodes"); Shows.Add(show); SaveData(); ChangedShow?.Invoke(); return(true); }
public void Update(Type t) { if (t == typeof(Movie)) { var _actualMovies = _db.GetObjects <Movie>(); Movies.Clear(); foreach (var movie in _actualMovies) { Movies.Add(movie); } var _actualShows = _db.GetObjects <Show>(); RemoveFilter(); Shows.Clear(); foreach (var show in _actualShows) { Shows.Add(show); } var _day = DateTime.ParseExact(_showDateFilter, "dd/MM/yyyy", null); ApplyDateFilter(_day); } else if (t == typeof(Show)) { var _actualShows = _db.GetObjects <Show>(); Shows.Clear(); // RemoveFilter(); foreach (var show in _actualShows) { Shows.Add(show); } var day = DateTime.ParseExact(_showDateFilter, "dd/MM/yyyy", null); // ApplyDateFilter(day); } else if (t == typeof(Reservation)) { var _actualReservations = _db.GetObjects <Reservation>(); App.Current.Dispatcher.Invoke(delegate { Reservations.Clear(); foreach (var reservation in _actualReservations) { Reservations.Add(reservation); } }); } }
public void AddTest() { // Arrange. var movies = PopulateMovies(); var shows = new Shows(); var showsExpected = new Shows(); Show showExpected = new Show(1, Convert.ToDateTime("2017-12-12 12:00"), 120, 15, movies.Items[1]); showsExpected.Items.Add(showExpected.ID, showExpected); // Act. shows.Add(Convert.ToDateTime("2017-12-12 12:00"), 120, 15, movies.Items[1]); // Assert. var expected = true; var actual = showsExpected.Items[1].Equals(shows.Items[1]); Assert.AreEqual(expected, actual); }
private void LoadTrendingShows(int page) { IsLoading = true; _tvshowtimeApiService.GetTrendingShows(page, _pageSize) .Subscribe(async(exploreResponse) => { await DispatcherHelper.ExecuteOnUIThreadAsync(() => { foreach (var show in exploreResponse.Shows) { // Do not add the same show twice if (Shows.Any(s => s.Id == show.Id)) { continue; } var exploreShowViewModel = new ExploreShowViewModel { Id = show.Id, Name = show.Name, Overview = show.Overview, AllImages = show.AllImages, Followed = show.Followed, Original = show }; Shows.Add(exploreShowViewModel); } IsLoading = false; }); }, async(error) => { await DispatcherHelper.ExecuteOnUIThreadAsync(() => { IsLoading = false; }); _toastNotificationService.ShowErrorNotification("An error happened. Please retry later."); }); }
public async Task ShowShows() { ShowFilters = "True"; Model.Requests.ShowSearchRequest request = new Model.Requests.ShowSearchRequest(); if (Genre != null) { request.Genre = Genre; if (request.Genre == "All") { request.Genre = ""; } } request.Rating = Rating; var shows = await _showsApi.Get <List <Model.Show> >(request); shows.Sort((a, b) => a.Title.CompareTo(b.Title)); Shows.Clear(); foreach (var show in shows) { Shows.Add(show); } if (Genres.Count == 0) { var list = new List <string>(); foreach (var show in shows) { list.Add(show.Genre); } list = list.Distinct().ToList(); list.Sort(); list.Insert(0, "All"); foreach (var genre in list) { Genres.Add(genre); } } }
public async Task OnSearch() { if (Search != null) { Genre = "All"; Rating = 0; Model.Requests.ShowSearchRequest request = new Model.Requests.ShowSearchRequest() { Title = Search }; var shows = await _showsApi.Get <List <Model.Show> >(request); Shows.Clear(); shows.Sort((a, b) => a.Title.CompareTo(b.Title)); foreach (var show in shows) { Shows.Add(show); } } }
public LightShow(XmlDocument ShowXMLData) { ConsoleOut("Loading inbound XML data", 0); XmlNodeList itemNodes = ShowXMLData.SelectNodes("//lightShow/shows/*"); foreach (XmlNode showNode in itemNodes) { Show thisShow = new Show { ShowID = Convert.ToInt32(showNode.Attributes["id"].Value), ShowName = showNode.Attributes["name"].Value, Iterations = Convert.ToInt32(showNode.Attributes["iterations"].Value), Speed = Convert.ToInt32(showNode.Attributes["speed"].Value), IsDynamic = false }; if (showNode.Attributes["dynamic"] != null) { thisShow.IsDynamic = true; thisShow.DynamicRangeStart = Convert.ToInt32(showNode.Attributes["rangeStart"].Value); thisShow.DynamicRangeEnd = Convert.ToInt32(showNode.Attributes["rangeEnd"].Value); thisShow.Step = Convert.ToInt32(showNode.Attributes["step"].Value); } else { foreach (XmlNode patternNode in showNode.SelectNodes("pattern")) { byte bytePattern = Convert.ToByte(patternNode.InnerText, 2); thisShow.ShowBytes.Add(bytePattern); } foreach (XmlNode byteNode in showNode.SelectNodes("byte")) { byte bytePattern = (byte)Convert.ToInt32(byteNode.InnerText); thisShow.ShowBytes.Add(bytePattern); } } ConsoleOut(String.Format("Found node {0} called '{1}'", thisShow.ShowID, thisShow.ShowName), 1); Shows.Add(thisShow); } }
public void AddShow(DateTime showDateTime) { try { CinemaMovieShowBooking show = new CinemaMovieShowBooking { ShowDateTime = showDateTime }; if (LockedCinema != null) { show.CinemaName = LockedCinema.Cinema; show.CinemaTown = LockedCinema.Town; } if (LockedMovie != null) { show.MovieTitle = LockedMovie.Title; show.MovieGenre = LockedMovie.Genre; show.MovieDuration = LockedMovie.Duration; show.MovieDirector = LockedMovie.Director; show.MovieReleaseDate = LockedMovie.ReleaseDate; } if (LockedBooking != null) { show.BookingMail = LockedBooking.BookingMail; show.BookingPhone = LockedBooking.BookingPhone; } repo.Add(show); ShowVM showVM = new ShowVM { ShowDateTime = showDateTime, Locked = false }; Shows.Add(showVM); SelectedShow = showVM; } catch (Exception) { throw; } }
public async void SearchShow() { IsSearchCompleted = false; IsWorking = true; string query = ShowName; List <Show> shows = await Task <List <Show> > .Factory.StartNew(() => { try { return(informationProvider.GetShows(query)); } catch { return(null); } }); IsWorking = false; Execute.BeginOnUIThread(() => { Shows.Clear(); IsSearchCompleted = true; if (shows == null) { Error = "Provider failed to return information."; return; } Error = null; foreach (Show show in shows) { Shows.Add(show); } }); }
public void AddShow(Show show) { try { if (!File.Exists("shows.csv")) { throw new FileNotFoundException(); } } catch (FileNotFoundException) { System.Console.WriteLine("File was not found!"); System.Console.WriteLine("Want to create the show.csv? y/n"); string wantNewFile = Console.ReadLine(); //creates file for user if they want it if (wantNewFile.Equals("y")) { filePath = "shows.csv"; StreamWriter sw = new StreamWriter(filePath, true); } } try { // iterate through each show obj until theres no more greater, then add one show.showId = Shows.Max(s => s.showId) + 1; StreamWriter sw = new StreamWriter(filePath, true); sw.WriteLine($"ID: {show.showId}, Title: {show.showTitle}, Season{show.showSeason} Ep. {show.showEpisode}, Writers: {string.Join(", ", show.showWriters)}"); sw.Close(); // add show details to Lists Shows.Add(show); } catch (Exception e) { Console.WriteLine(e.Message); } }
private void LoadTrendingShows(int page) { _isLoadingShows = true; _tvshowtimeApiService.GetTrendingShows(page, _pageSize) .Subscribe(async(exploreResponse) => { await DispatcherHelper.ExecuteOnUIThreadAsync(() => { foreach (var show in exploreResponse.Shows) { // Do not add the same show twice if (Shows.Any(s => s.Id == show.Id)) { continue; } var exploreShowViewModel = new ExploreShowViewModel { Id = show.Id, Name = show.Name, Overview = show.Overview, AllImages = show.AllImages, Followed = show.Followed, Original = show }; Shows.Add(exploreShowViewModel); } _isLoadingShows = false; }); }, (error) => { throw new Exception(); }); }
public override void ReadJson(JObject obj) { base.ReadJson(obj); if (obj["shows"] as JObject != null) { foreach (var prop in ((JObject)obj["shows"]).Properties()) { Shows.Add(new CouchFunctionDefinition { Name = prop.Name, Function = obj["shows"][prop.Name].Value <string>() }); } } if (obj["lists"] as JObject != null) { foreach (var prop in ((JObject)obj["lists"]).Properties()) { Lists.Add(new CouchFunctionDefinition { Name = prop.Name, Function = obj["lists"][prop.Name].Value <string>() }); } } }
/// <summary> /// Load movies asynchronously /// </summary> public override async Task LoadShowsAsync(bool reset = false) { await LoadingSemaphore.WaitAsync(); StopLoadingShows(); if (reset) { Shows.Clear(); Page = 0; } var watch = Stopwatch.StartNew(); Page++; if (Page > 1 && Shows.Count == MaxNumberOfShows) { Page--; LoadingSemaphore.Release(); return; } Logger.Info( $"Loading shows favorite page {Page}..."); HasLoadingFailed = false; try { IsLoadingShows = true; var imdbIds = await UserService.GetFavoritesShows(Page); if (!NeedSync) { var shows = new List <ShowLightJson>(); await imdbIds.shows.ParallelForEachAsync(async imdbId => { try { var show = await ShowService.GetShowLightAsync(imdbId); if (show != null) { show.IsFavorite = true; shows.Add(show); } } catch (Exception ex) { Logger.Error(ex); } }); var updatedShows = shows.OrderBy(a => a.Title) .Where(a => (Genre == null || a.Genres.Contains(Genre.EnglishName)) && a.Rating.Percentage >= Rating * 10); foreach (var show in updatedShows.Except(Shows.ToList(), new ShowLightComparer())) { var pair = Shows .Select((value, index) => new { value, index }) .FirstOrDefault(x => string.CompareOrdinal(x.value.Title, show.Title) > 0); if (pair == null) { Shows.Add(show); } else { Shows.Insert(pair.index, show); } } } else { var showsToDelete = Shows.Select(a => a.ImdbId).Except(imdbIds.allShows); var showsToAdd = imdbIds.allShows.Except(Shows.Select(a => a.ImdbId)); foreach (var movie in showsToDelete.ToList()) { Shows.Remove(Shows.FirstOrDefault(a => a.ImdbId == movie)); } var shows = showsToAdd.ToList(); var showsToAddAndToOrder = new List <ShowLightJson>(); await shows.ParallelForEachAsync(async imdbId => { try { var show = await ShowService.GetShowLightAsync(imdbId); if ((Genre == null || show.Genres.Contains(Genre.EnglishName)) && show.Rating.Percentage >= Rating * 10) { showsToAddAndToOrder.Add(show); } } catch (Exception ex) { Logger.Error(ex); } }); foreach (var show in showsToAddAndToOrder.Except(Shows.ToList(), new ShowLightComparer())) { var pair = Shows .Select((value, index) => new { value, index }) .FirstOrDefault(x => string.CompareOrdinal(x.value.Title, show.Title) > 0); if (pair == null) { Shows.Add(show); } else { Shows.Insert(pair.index, show); } } } IsLoadingShows = false; IsShowFound = Shows.Any(); CurrentNumberOfShows = Shows.Count; MaxNumberOfShows = imdbIds.nbShows; await UserService.SyncShowHistoryAsync(Shows).ConfigureAwait(false); } catch (Exception exception) { Page--; Logger.Error( $"Error while loading shows favorite page {Page}: {exception.Message}"); HasLoadingFailed = true; Messenger.Default.Send(new ManageExceptionMessage(exception)); } finally { NeedSync = false; watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; Logger.Info( $"Loaded shows favorite page {Page} in {elapsedMs} milliseconds."); LoadingSemaphore.Release(); } }