public UserManagementController(UpnoidContext context, UserManager <ApplicationUser> userManager,
                                 RoleManager <IdentityRole> roleManager)
 {
     _context     = context;
     _userManager = userManager;
     _roleManager = roleManager;
 }
예제 #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, ILoggerFactory loggerFactory
                              , UpnoidContext context)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseApplicationInsightsRequestTelemetry();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseBrowserLink();
                app.UseSession();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseApplicationInsightsExceptionTelemetry();

            app.UseStaticFiles();

            app.UseIdentity();

            new UserRoleSeed(app.ApplicationServices.GetService <RoleManager <IdentityRole> >()).Seed();

            // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715
            app.UseFacebookAuthentication(new FacebookOptions()
            {
                AppId     = Configuration["Authentication:Facebook:AppId"],
                AppSecret = Configuration["Authentication:Facebook:AppSecret"]
            });

            app.UseGoogleAuthentication(new GoogleOptions()
            {
                ClientId     = Configuration["Authentication:Google:ClientId"],
                ClientSecret = Configuration["Authentication:Google:ClientSecret"]
            });

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "pagination",
                    template: "Customers/Page{page}",
                    defaults: new { Controller = "Customers", action = "Index" });

                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
            //  DbInitializer.Initialize(context);
        }
예제 #3
0
 public MoviesController(UpnoidContext context)
 {
     _context = context;
 }
예제 #4
0
 public CustomersController(UpnoidContext context)
 {
     _context = context;
 }
예제 #5
0
 public RentalsController(UpnoidContext context)
 {
     _context = context;
 }
예제 #6
0
        public static void Initialize(UpnoidContext context)
        {
            //context.Database.EnsureCreated();
            //look for any genres

            if (context.Genres.Any())
            {
                return; //DB has been added
            }

            var genres = new Genre[]
            {
                new Genre {
                    Name = "Comedy"
                },
                new Genre {
                    Name = "Thriller"
                },
                new Genre {
                    Name = "Action"
                },
                new Genre {
                    Name = "Drama"
                },
                new Genre {
                    Name = "Horror"
                },
                new Genre {
                    Name = "Romance"
                }
            };

            foreach (Genre i in genres)
            {
                context.Genres.Add(i);
            }
            context.SaveChanges();

            if (context.Genres.Any())
            {
                return; //DB has been added
            }
            // look for any movies
            var movies = new Movie[]
            {
                //  new Movie {Name = "Fate and Furius", GenreId='Action', NumberInStock=15, Price=18, ReleaseDate=DateTime.Parse("2016-03-11"), DateAdded=DateTime.Now},
                new Movie {
                    Name = "Thriller"
                },
                new Movie {
                    Name = "Action"
                },
                new Movie {
                    Name = "Drama"
                },
                new Movie {
                    Name = "Horror"
                },
                new Movie {
                    Name = "Romance"
                }
            };

            foreach (Movie i in movies)
            {
                context.Movies.Add(i);
            }
            context.SaveChanges();
        }