public CreateMovieParser(MovieDbCommand movieCmd, CastMemberDbCommand castMemberCmd, CountryDbCommand countryCmd, GenreDbCommand genreCmd) { this.movieCmd = movieCmd; this.castMemberCmd = castMemberCmd; this.countryCmd = countryCmd; this.genreCmd = genreCmd; }
public CommandsFactory( MovieDbContext dbContext, MovieDbCommand movieCmd, CastMemberDbCommand castMemberCmd, CountryDbCommand countryCmd, GenreDbCommand genreCmd) { this.dbContext = dbContext; this.movieCmd = movieCmd; this.castMemberCmd = castMemberCmd; this.countryCmd = countryCmd; this.genreCmd = genreCmd; }
public static void AddMovies(MovieDbContext dbContext) { var jsonStr = File.ReadAllText("InitialData\\sample-movies.json"); var movieCmd = new MovieDbCommand(dbContext); var movieParser = new CreateMovieParser( new MovieDbCommand(dbContext), new CastMemberDbCommand(dbContext), new CountryDbCommand(dbContext), new GenreDbCommand(dbContext) ); var movies = JObject.Parse(jsonStr)["movies"] .Children() .Select(x => x.ToObject <MovieJsonModel>()) .ToList(); movies.ForEach(m => { movieParser.ParseFromStr(m.Title, m.Year, m.Country, m.Director, m.Rating, m.Genre, m.Actors); }); }