public static void FillDatabaseInfo(ActorScraper scraper) { Console.WriteLine("\r\nTransfering to database...", ProfileManager.InfoColor); foreach (var actor in scraper.UniqueActors) { AddActorToDb(actor.Name, actor.Surname, actor.Born); } foreach (var movie in scraper.UniqueFilms) { AddMovieToDb(movie.Name, movie.Rating, movie.Genre, movie.Year); } Console.WriteLine("Starting actors and films query...", ProfileManager.InfoColor); foreach (var actor in scraper.UniqueActors) { var actorId = SelectActorId(actor.Name, actor.Surname); foreach (var film in actor.Films) { var movieId = SelectFilmId(film.Name); SelectActorFilmId(actorId, movieId); } } }
static void Main() { var profile = ProfileManager.GetProfile(); var actorDict = EnterActors(); var scraper = new ActorScraper(profile); scraper.ScrapeActors(actorDict); SqlQueries.ActorObjList = scraper.UniqueActors.ToList(); Database.FillDatabaseInfo(scraper); Console.WriteLine("Data transfer complete.", ProfileManager.SuccessColor); Console.Write("\r\nActor with most films: ", ProfileManager.ResultColor); Database.GetActorWithMostFilms(); Console.Write("\r\nActor with biggest film rating: ", ProfileManager.ResultColor); Database.GetFilmWithBiggestRating(); if (SqlQueries.ActorObjList.Count > 1) { Console.WriteLine($"\r\nThe {SqlQueries.ActorObjList.Count} actors Co-Star in all these films:", ProfileManager.ResultColor); Database.ActorsAndMovies(SqlQueries.UniversalString()); if (SqlQueries.ActorObjList.Count > 2) { Database.ActorsAndMovies(SqlQueries.CoStarMethod()); } } Database.CloseConnections(); Console.WriteLine("\r\nPress any key to exit...", ProfileManager.InfoColor); Console.ReadKey(); }
new ObservableCollection <Film>(); //{new Film("Test Film", 10, "2017", "Cool genre")}; //TODO: Make this threaded public static void SearchActors() { // Get a dict of actors var actorDict = new Dictionary <string, string>(); foreach (Actor actor in SelectedActors) { var pair = actorNameToIdPair(actor.Fullname); actorDict.Add(pair.Key, pair.Value); } // Scrape var scraper = new ActorScraper(); scraper.ScrapeActors(actorDict); // Update FilmsResult FilmsResult.Clear(); foreach (var film in scraper.GetFilmsInCommon()) { FilmsResult.Add(film); } }