Example #1
0
        public static void SeedMovieDatabase(this MovieCollectionContext context)
        {
            if (context.Movies.Any())
            {
                return;
            }

            var movies = new List <Movie>()
            {
                new Movie()
                {
                    Title         = "Jurassic Park",
                    Description   = "Dinosaurs run amok on an island.",
                    Rating        = Rating.PG13,
                    ReleaseDate   = Convert.ToDateTime("06/11/1993"),
                    InventoryDate = DateTime.Now,
                    UpdatedDate   = DateTime.Now
                },
                new Movie()
                {
                    Title         = "Star Wars",
                    Description   = "A long time ago, in a galaxy far, far away....",
                    Rating        = Rating.PG,
                    ReleaseDate   = Convert.ToDateTime("05/25/1977"),
                    InventoryDate = DateTime.Now,
                    UpdatedDate   = DateTime.Now
                },
                new Movie()
                {
                    Title         = "Taxi Driver",
                    Description   = "An NYC cabbie turns violent.",
                    Rating        = Rating.R,
                    ReleaseDate   = Convert.ToDateTime("02/08/1976"),
                    InventoryDate = DateTime.Now,
                    UpdatedDate   = DateTime.Now
                }
            };

            context.Movies.AddRange(movies);
            context.SaveChanges();
        }
Example #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env,
                              MovieCollectionContext movieCollectionContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // seed movie db
            movieCollectionContext.SeedMovieDatabase();

            // using AutoMapper to quickly and easily map entites to DTOs
            AutoMapper.Mapper.Initialize(config =>
            {
                config.CreateMap <Entities.Movie, Models.MovieDto>();
                config.CreateMap <Models.MovieDto, Entities.Movie>();
                config.CreateMap <MovieCreateDto, Movie>();
                config.CreateMap <MovieUpdateDto, Movie>();
                config.CreateMap <Movie, MovieUpdateDto>();
            });

            app.UseMvc();
        }
Example #3
0
 public HomeController(ILogger <HomeController> logger, MovieCollectionContext con)
 {
     _logger = logger;
     context = con;
 }
 public MoviesRepository(MovieCollectionContext context)
 {
     _context = context;
 }
Example #5
0
 public CountryRepository(MovieCollectionContext context) : base(context)
 {
 }
Example #6
0
 public ProducerRepository(MovieCollectionContext context) : base(context)
 {
 }
Example #7
0
 public MovieRepository(MovieCollectionContext context) : base(context)
 {
 }