Beispiel #1
0
        public static void Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var service = scope.ServiceProvider;
                var context = service.GetRequiredService <MovieListingDbContext>();

                MovieDataGenerator.GenerateData(service);
            }

            host.Run();
        }
Beispiel #2
0
        /// <summary>
        /// Updates the given movie entity if contained in the current context, else adds the new movie.
        /// </summary>
        /// <param name="movie"></param>
        /// <returns></returns>
        public bool SaveOrUpdate(Movie movie)
        {
            var hasMovie = _movieListingDbContext.GetMovie(movie.Id) != null;

            if (hasMovie)
            {
                _movieListingDbContext.Update(movie);
            }
            else
            {
                _movieListingDbContext.Add(movie);
            }
            MovieDataGenerator.ExportData(_movieListingDbContext.GetAllMovies());
            return(true);
        }