Exemplo n.º 1
0
        private void RetrieveAndInsertFilm(int id)
        {
            var film = _httpRetriever.RetrieveMovie(id);
            // some of the genres are not contained in /genre/movie/list
            var genres      = _httpRetriever.RetrieveGenresFromMovie(id);
            var movieGenres = _httpRetriever.RetrieveMovieGenres(id);
            var countries   = _httpRetriever.RetrieveMovieProductionCountries(id).ToList();

            _movieDao.InsertMovie(film);
            _countriesDao.InsertCountries(countries);
            _countriesDao.InsertMovieCountries(film.MovieId, countries.Select(x => x.CountryId).ToList());
            _genresDao.InsertGenres(genres);
            _genresDao.InsertMovieGenres(movieGenres);
        }
Exemplo n.º 2
0
        private void addMovie_Click(object sender, EventArgs e)
        {
            var movie = new Movie(releaseDate.Value.Date,
                                  (int)id.Value,
                                  status.Text,
                                  revenue.Value,
                                  posterUrl.Text,
                                  title.Text,
                                  0);

            try
            {
                _movieDao.InsertMovie(movie);
                var countriesList =
                    (from object country in selectedCountries.Items select country.ToString().SplitInto2Vars().Item2)
                    .ToList();
                var movieId = int.Parse(id.Text);
                _countriesDao.InsertMovieCountries(movieId, countriesList);

                var genresList = new List <string>();
                genresList.AddRange(from object genre in selectedGenres.Items select genre.ToString());
                _genresDao.InsertMovieGenres(genresList.Select(x =>
                {
                    var genreId = int.Parse(x.SplitInto2Vars().Item2);
                    return(new MovieGenre(movieId, genreId));
                }));

                foreach (var crewItem in crewListbox.Items)
                {
                    var separated    = crewItem.ToString().SplitInto3Vars();
                    var crewPersonId = int.Parse(separated.Item3);
                    var crew         = new Crew(crewPersonId, movieId, crewJob.Text);
                    _crewDao.InsertCrew(crew);
                }
                foreach (var castItem in castListbox.Items)
                {
                    var separate     = castItem.ToString().SplitInto3Vars();
                    var castPersonId = int.Parse(separate.Item3);
                    var cast         = new Cast(castPersonId, movieId, castCharacter.Text);
                    _castDao.InsertCast(cast);
                }
                Close();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }