Ejemplo n.º 1
0
        private string CreateMovie()
        {
            var movieParser = new CreateMovieParser(
                this.movieCmd,
                this.castMemberCmd,
                this.countryCmd,
                this.genreCmd
                );

            movieParser.ParseFromConsole();

            this.dbContext.SaveChanges();

            return("Movie succesfully created!");
        }
Ejemplo n.º 2
0
        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);
            });
        }