private void buttonAddMovie_Click(object sender, EventArgs e) { Movie newMovie = new Movie(CurrentMovie.Name, CurrentMovie.Length); AllMovies.Add(newMovie); textBoxAllMovies.Text += CurrentMovie.Name + ", " + CurrentMovie.Length + " min." + Environment.NewLine; }
public async Task LoadAsync() { AllMovies.Clear(); var movies = await _movieRepository.GetAllAsync(); foreach (var movie in movies) { var modelWrapper = new MovieWrapper(movie); AllMovies.Add(modelWrapper); } }
private void buttonRandom_Click(object sender, EventArgs e) { textBoxAllMovies.Clear(); Movie Movie1 = new Movie("Lion King", 90); Movie Movie2 = new Movie("Wizard of OZ", 80); Movie Movie3 = new Movie("Mickey Mouse", 70); AllMovies.Add(Movie1); AllMovies.Add(Movie2); AllMovies.Add(Movie3); for (int i = 0; i < AllMovies.Count; ++i) { textBoxAllMovies.Text += AllMovies[i].Name + ", " + AllMovies[i].Length + " min." + Environment.NewLine; } }
private async void OpenAndFilterNavigationView(OpenAndFilterNavigationViewEventArgs args) { if (String.IsNullOrEmpty(args.SelectedItem)) { await LoadAsync(); } else { var filteredMovies = AllMovies.Where(m => m.Name.ToLower().StartsWith(args.SelectedItem.ToLower())); List <MovieWrapper> tempList = new List <MovieWrapper>(); foreach (var filteredMovie in filteredMovies) { tempList.Add(filteredMovie); } AllMovies.Clear(); foreach (var item in tempList) { AllMovies.Add(item); } } }
public async Task GetMoviesDataAsync() { if (AllMovies.Count != 0) { return; } System.Diagnostics.Debug.WriteLine("getting data"); Uri dataUri = new Uri("ms-appx:///DataSource/moviespots.json"); StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(dataUri); string jsonText = await FileIO.ReadTextAsync(file); JsonObject jsonObject = JsonObject.Parse(jsonText); JsonArray jsonArray = jsonObject["MovieSpots"].GetArray(); foreach (JsonValue value in jsonArray) { JsonObject movieJsonObject = value.GetObject(); Movie movie = new Movie { Title = movieJsonObject["Title"].GetString(), ReleaseYear = movieJsonObject["Release Year"].GetString(), StreetName = movieJsonObject["Locations"].GetString(), FunFacts = movieJsonObject["Fun Facts"].GetString(), ProductionCompany = movieJsonObject["Production Company"].GetString(), Distributor = movieJsonObject["Distributor"].GetString(), Director = movieJsonObject["Director"].GetString(), Writer = movieJsonObject["Writer"].GetString(), Actor1 = movieJsonObject["Actor 1"].GetString(), Actor2 = movieJsonObject["Actor 2"].GetString(), Actor = movieJsonObject["Actor "].GetString(), Latitude = movieJsonObject["Latitude"].GetNumber(), Longitude = movieJsonObject["Longitude"].GetNumber() }; AllMovies.Add(movie); } }