public void LoadMovies() { Movies.Add(new Movie() { Description = "An organized crime dynasty's aging patriarch transfers control of his clandestine empire to his reluctant son.", GenreId = 1, MovieId = 1, Title = "The Godfather" }); Movies.Add(new Movie() { Description = "Two imprisoned men bond over a number of years, finding solace and eventual redemption through acts of common decency.", GenreId = 2, MovieId = 2, Title = "The Shawshank Redemption" }); Movies.Add(new Movie() { Description = "In German-occupied Poland during World War II, industrialist Oskar Schindler gradually becomes concerned for his Jewish workforce after witnessing their persecution by the Nazis.", GenreId = 2, MovieId = 3, Title = "Schindler's List " }); }
private void bwMovies_DoWork(object sender, DoWorkProviderEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; _movieList = new Movies(); //XmlNamespaceManager nsmgr = new XmlNamespaceManager(movieXml.NameTable); //nsmgr.AddNamespace("atom", "http://www.w3.org/2005/Atom"); //nsmgr.AddNamespace("opensearch", "http://a9.com/-/spec/opensearch/1.1/"); movieXml.InnerXml = movieXml.InnerXml.Replace("atom:", ""); XmlNodeList movieNodes = movieXml.DocumentElement.SelectNodes("//entry/content"); //int thumbCount = movieXml.SelectNodes("//images/image[@type='Poster' and @size='thumb']").Count; // int movieCount = movieXml.SelectNodes("//movie").Count; //processDivider = (thumbCount < movieCount) ? movieCount : thumbCount; myTime.Start(); foreach (XmlNode movieNode in movieNodes) { if (movieNode.FirstChild.Name.ToLower() == "movie") { ObjectLoadedProviderEventArgs moviesArgs = new ObjectLoadedProviderEventArgs(this.LoadMovie(movieXml, worker, e)); _movieList.Add((Movie)moviesArgs.loadedObject); //OnObjectLoaded(moviesArgs); ReportObjectLoaded(moviesArgs.loadedObject); } } }
/// <summary> /// Load favorites movies /// </summary> public override async Task LoadMoviesAsync() { IsLoadingMovies = true; var favoritesMovies = await MovieHistoryService.GetFavoritesMoviesAsync(); var movies = favoritesMovies.ToList(); var moviesToAdd = movies.Except(Movies, new MovieShortComparer()).ToList(); var moviesToRemove = Movies.Except(movies, new MovieShortComparer()).ToList(); foreach (var movie in moviesToAdd) { Movies.Add(movie); } foreach (var movie in moviesToRemove) { Movies.Remove(movie); } IsLoadingMovies = false; await MovieService.DownloadCoverImageAsync(moviesToAdd); IsMovieFound = Movies.Any(); CurrentNumberOfMovies = Movies.Count(); MaxNumberOfMovies = movies.Count(); }
public ActionResult Create(Movie movie) { // Retreive from the Application dictionary the reference of the contacts instance Movies movies = (Movies)HttpRuntime.Cache["Movies"]; // Pass the Http post Request object to UpLoadAvatar // so that it can retreive its uploaded image file movie.UpLoadAvatar(Request); // insert the new contact and retreive its Id int newMovieID = movies.Add(movie); // Retreive from the Application dictionary the reference of the Friends instance Friends Friends = (Friends)HttpRuntime.Cache["Friends"]; // Extract the friends Id list from the hidden input FriendsListItems // embedded in the Http post request String[] FriendsListItems = Request["FriendsListItems"].Split(','); // Add friends to the Friends collection foreach (String friendId in FriendsListItems) { if (!String.IsNullOrEmpty(friendId)) { Friends.Add(new Friend(newMovieID, int.Parse(friendId))); } } // Return the Index action of this controller return(RedirectToAction("index")); }
private async void SaveMovie(object movieObject) { Movie movie = movieObject as Movie; if (movie != null) { IsBusy = true; if (movie.Id > 0) { Movie updatedMovie = await movieService.Update(movie); if (updatedMovie != null) { int pos = Movies.IndexOf(updatedMovie); Movies.RemoveAt(pos); Movies.Insert(pos, updatedMovie); } } else { Movie addedMovie = await movieService.Add(movie); if (addedMovie != null) { Movies.Add(addedMovie); } } IsBusy = false; } Back(); }
public MainWindowViewModel() { Movies.Add("Black Panther"); Movies.Add("Iron Man"); Movies.Add("The Winner"); Movies.Add("Winning"); Movies.Add("Win Win"); Movies.Add("Batman Begins"); Movies.Add("Wonder Woman"); Movies.Add("Gone with the Wind"); Movies.Add("Winnie the Pooh"); Movies.Add("Fast & Furious"); Movies.Add("The Martian"); moviesView = CollectionViewSource.GetDefaultView(Movies); moviesView.Filter = (w) => { return((w as string).Contains(Filter, StringComparison.CurrentCultureIgnoreCase)); }; this.breeds = new ObservableCollection <Breed>(InitializeBreeds()); _rootPerson = GetFamilyTree(); this.rootPersons = new List <Person>() { _rootPerson }; }
private async Task InitAsync(Starship starship) { IsLoading = true; if (starship != null) { Starship = starship; Movies.Clear(); foreach (var film in Starship.films) { var currentFilm = await _filmRepository.GetFilmAsync(film) ?? await _dataService.GetSingleByUrl <Film>(film); Movies.Add(currentFilm); } Movies = Movies.OrderBy(item => item.episode_id).ToObservableCollection(); People.Clear(); foreach (var person in starship.pilots) { var currentPerson = await _peopleRepository.GetPeopleAsync(person) ?? await _dataService.GetSingleByUrl <People>(person); People.Add(currentPerson); } People = People.OrderBy(item => item.name).ToObservableCollection(); } IsLoading = false; }
public int MoviesTotalRunTime() { string connectionString = @"Data Source=rpsdp.ctvssf2oqpbl.us-east-1.rds.amazonaws.com; Initial Catalog=Movies;User ID=admin; Password=kereneritrea"; SqlConnection con = new SqlConnection(connectionString); string queryString = "SELECT * FROM MOVIE"; SqlCommand command = new SqlCommand(queryString, con); con.Open(); // the list of movies should be declared here .... anh's feedback using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Movies.Add( new Movie(Convert.ToInt32(reader[0]), reader[1].ToString(), Convert.ToInt32(reader[2]), Convert.ToInt32(reader[3])) ); } } var total = 0; foreach (Movie m in this.Movies) { total += m.RunTime; } return(total); }
public void AddMovie(Movie movie) { if (ValidateMovie(movie)) { Movies.Add(movie); } }
protected override async Task OnInitializedAsync() { var keys = await GetRecentlyViewedKeys(); if (keys is not null && keys.Count() is not 0) { foreach (var key in keys) { if (key.Contains("movie")) { var movie = await LocalStorage.GetItemAsync <MovieDetails>(key); Movies.Add(movie); } if (key.Contains("tv")) { var tvShow = await LocalStorage.GetItemAsync <TVShowDetails>(key); TVShows.Add(tvShow); } } } if (Movies.Count() is 0 && TVShows.Count() is 0) { DisplayMessage = true; Message = "There is no recently viewed items."; } }
private async void MainPage_Loaded(object sender, RoutedEventArgs e) { await Task.Run(() => { using (UnitOfWork uow = new UnitOfWork()) { uow.Migrate(); } }); UserDO.CreateOrSetUser("Angie"); Movies.Clear(); IEnumerable <LatestViewModel> latest = Registry.Instance.FetchLatest(); foreach (LatestViewModel m in latest) { Movies.Add(m); } UserName.Content = Registry.Instance.User.Name; prDatabase.IsActive = false; prDatabase.Visibility = Visibility.Collapsed; txtStatus.Text = "Latest watched:"; btnNewEpisodes.Visibility = Visibility.Visible; }
public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { var personId = (int)parameter; var service = new MovieBrowserService(); //Don't borther the server if we dont have to if (Person == null) { Person = await service.GetPerson(personId); } //Load the movies if empty and order by descending popularity if (Movies.Count == 0) { PersonMovieCredits movieCredits = await service.GetPersonMovieCredits(personId); var movies = new List <PersonMovieCreditsCast>(movieCredits.cast.OrderByDescending(x => x.popularity)); foreach (var item in movies) { Movies.Add(item); } } //Load the tv shows if empty and order by descending popularity if (TvShows.Count == 0) { PersonTvShowCredits tvShowCredits = await service.GetPersonTvShowCredits(personId); var tvShows = new List <PersonTvShowCreditsCast>(tvShowCredits.cast.OrderByDescending(x => x.popularity)); foreach (var item in tvShows) { TvShows.Add(item); } } await base.OnNavigatedToAsync(parameter, mode, state); }
private void GetMoviesCompleted(object sender, DownloadStringCompletedEventArgs e) { try { if (e.Error != null) { Deployment.Current.Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message)); } else { var multiplexId = _appSettings.Multiplex.MultiplexId; var items = DataService.ParseMovieCollection(e.Result, multiplexId); Movies.Clear(); foreach (var movie in items) { Movies.Add(movie); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { UpdateProgressBar(false); } }
/// <summary> /// Read a Movie data file. /// /// Format of file: /// First line has MovieId followed by a colon. /// Subsequent lines have: ReviewerId,Rating,ReviewDate /// </summary> /// <param name="dataFile">Name of file to read.</param> /// <returns>True if successfully read, false if no such file or failed to read.</returns> public bool LoadFile(string dataFile) { int movieId = 0; try { var lines = File.ReadLines(dataFile); movieId = Int32.Parse(lines.First().Trim().Replace(":", "")); var movie = new Movie(movieId); Movies.Add(movie); foreach (var fields in lines.Skip(1).Select(line => line.Trim().Split(new[] { ',' }))) { // Skip the ReviewDate. Not yet using this information. var review = new Review { ReviewerId = Int32.Parse(fields[0]), Rating = Int32.Parse(fields[1]) }; movie.Add(review); if (!ReviewersById.TryGetValue(review.ReviewerId, out Reviewer reviewer)) { reviewer = new Reviewer(review.ReviewerId); ReviewersById[review.ReviewerId] = reviewer; } reviewer.Add(movieId, (uint)review.Rating); } } catch (Exception e) { Logger.Error($"LoadFile failed for file {dataFile} with error: {e.Message}"); return(false); } return(true); }
public static void OpenListFromFile(string fileName) { if (String.IsNullOrEmpty(fileName) || fileName == "N/A") { return; } EmptyStorage(); // read from file with deserialize json using (StreamReader file = File.OpenText(fileName)) { JsonTextReader reader = new JsonTextReader(file); reader.SupportMultipleContent = true; while (true) { if (!reader.Read()) { break; } JsonSerializer serializer = new JsonSerializer(); Movie movie = serializer.Deserialize <Movie>(reader); Movies.Add(movie); UpdateGenres(movie.Genre); } } }
public async Task LoadMoreItemsAsync() { if (!GetMoreResults) { return; } var moviesData = await movieService.GetMoviesAsync(CurrentPageNumber, CultureInfo.CurrentCulture.Name, SearchTerm); if (moviesData == null || moviesData.Movies == null || !moviesData.Movies.Any()) { return; } else { TotalPages = moviesData.TotalPages; for (int i = 0; i < moviesData.Movies.Length; i++) { moviesData.Movies[i].GenreNames = genreService.GetGenreNames(moviesData.Movies[i].GenreIds, Genres); Movies.Add(moviesData.Movies[i]); } } CurrentPageNumber++; GetMoreResults = TotalPages > 0 && CurrentPageNumber < TotalPages; }
async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Movies.Clear(); var movies = await DataStore.GetMovieAsync(true); if (movies.Any()) { foreach (var item in movies) { Movies.Add(item); } } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
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(); } }
public bool AddMovie() { Movie M1 = new Movie(); Console.WriteLine("Enter Theatre Name: "); M1.ThName = Console.ReadLine(); if (M1.ThName != "") { foreach (Theatre th in Theatres) { if (th.TheatreName == M1.ThName) { Console.WriteLine("Enter Movie Name: "); M1.MovieName = Console.ReadLine(); Movies.Add(M1); Console.WriteLine(M1.MovieName + " added to " + M1.ThName); return(true); } } Console.WriteLine("Theatre not found."); return(false); } else { Console.WriteLine("Theatre name cannot be null."); return(false); } }
public void OnGet() { Movies.Add(new Movies1 { MovieId = "j235z", Title = "Booty Call", Director = "Jamiee Foxx", Rating = 87.5 }); Movies.Add(new Movies1 { MovieId = "2hj3", Title = "Black Panther", Director = "Kenyatta Hayes", Rating = 2.3 }); Movies.Add(new Movies1 { MovieId = "234hjke", Title = "Coming To America 2", Director = "Charlie Murphy", Rating = 90.3 }); MainTitle = "Movie Time!"; Movies1 = new string[] { "Booty Call", "Black Panther", "Coming To America 2" }; }
private void updateObservable() { Movies.Clear(); foreach (Movie movie in movieList.Instance.listMovieValues) { Movies.Add(movie); } }
static void AddMovieImagesToCache(TmdbMovieImages images) { if (images != null) { images.RequestAge = DateTime.Now.ToString(); Movies.Add(images); } }
/* * Function: Add Record to Collection and Database */ public void AddRecordToRepo(Movie movie) { if (movie == null) { throw new ArgumentNullException("Error: The argument is Null"); } Movies.Add(movie); }
public async Task Load() { IsLoading = true; try { if (Movies.Any()) { _logManager.LogDebug("Movies already loaded, skipping to reload."); return; } IList <Movie> movies = (await _movieService.GetMovies()).ToList(); foreach (Movie movie in movies.OrderBy(q => q.Name)) { Movies.Add(movie); } ContinueWatchingMovies = new ObservableCollectionEx <Movie>( Movies.Where(q => q.PlaybackPosition.Ticks > 0)); RaisePropertyChanged(nameof(ContinueWatchingMovies)); RecentlyReleasedMovies = new ObservableCollectionEx <Movie>(Movies .Where(q => q.PremiereDate > DateTime.Now.AddMonths(-18)) .OrderByDescending(q => q.PremiereDate) .Take(20).ToList()); RaisePropertyChanged(nameof(RecentlyReleasedMovies)); MovieGenres = _movies.SelectMany(q => q.Genres).GroupBy(q => q).Select(group => group.Key) .OrderBy(x => x).ToList(); FirstFavoriteGenre = MovieGenres[0]; SecondFavoriteGenre = MovieGenres[1]; MoviesFirstFavoriteGenre = new ObservableCollectionEx <Movie>(Movies .Where(q => q.Genres.Any(w => w == FirstFavoriteGenre)) .OrderByDescending(q => q.OfficialRating) .Take(20).ToList()); RaisePropertyChanged(nameof(MoviesFirstFavoriteGenre)); MoviesSecondFavoriteGenre = new ObservableCollectionEx <Movie>(Movies .Where(q => q.Genres.Any(w => w == SecondFavoriteGenre)) .OrderByDescending(q => q.OfficialRating) .Take(20).ToList()); RaisePropertyChanged(nameof(MoviesSecondFavoriteGenre)); OrderByName(); } catch (Exception xc) { _logManager.LogError(xc, "An error occurred while loading movies."); } finally { IsLoading = false; } }
public void Setup() { System.Console.WriteLine($"Welcome to {Title}!"); Movie lotr = new Movie("Lord of The Rings"); Movie donnieDarko = new Movie("Donnie Darko"); Movies.Add(lotr); Movies.Add(donnieDarko); }
public void Add() { var nMovie = new MovieViewModel(); nMovie.PropertyChanged += Movie_OnNotifyPropertyChanged; Titles.Add(nMovie); myMovie.Add(nMovie); SelectedIndex = Titles.IndexOf(nMovie); }
private void updateObservable() { Movies.Clear(); foreach (Movie obj in NeoSingleton._readByMeta(ActorsComboBox.SelectedItem, DirectorsComboBox.SelectedItem, GenresComboBox.SelectedItem)) { Movies.Add(obj); } }
private void formMovies() { Movies.Clear(); foreach (Movie movie in NeoSingleton._readByMultiple((int)(RuntimeRange.RangeMin), (int)(RuntimeRange.RangeMax), (int)YearRange.RangeMin, (int)YearRange.RangeMax, ActorsList.SelectedItems.ToArray(), DirectorsList.SelectedItems.ToArray(), GenresList.SelectedItems.ToArray())) { Movies.Add(movie); } }
public void Setup() { System.Console.WriteLine($"Welcome to {Title}!"); Movie toyStory = new Movie("Toy Story"); Movie onward = new Movie("on ward"); Movies.Add(toyStory); Movies.Add(onward); }
public async Task GetUpcomingMoviesAsync() { if (!GetMoreResults) { return; } if (IsBusy) { return; } if (Connectivity.NetworkAccess != NetworkAccess.Internet) { await DisplayAlert(AppResources.ErrorNoConnection); return; } IsBusy = true; try { if (!Genres.Any()) { await GetGenresAsync(); } var moviesData = await movieService.GetUpcomingMoviesDataAsync(CurrentPageNumber, CultureInfo.CurrentCulture.Name); if (moviesData != null) { TotalPages = moviesData.TotalPages; for (int i = 0; i < moviesData.Movies.Length; i++) { moviesData.Movies[i].GenreNames = genreService.GetGenreNames(moviesData.Movies[i].GenreIds, Genres); Movies.Add(moviesData.Movies[i]); } } else { TotalPages = 0; } CurrentPageNumber++; GetMoreResults = TotalPages > 0 && CurrentPageNumber < TotalPages; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); await DisplayAlert(AppResources.ErrorSearchingMovies); } finally { IsBusy = false; } }