예제 #1
0
        public ControllerTest()
        {
            SetupSimpleConfiguration();
            string constr = Environment.GetEnvironmentVariable("SQLSERVER_CONNECTION_STRING");

            if (constr == null)
            {
                constr = Config["DefaultConnection"];;
            }
            var optionsBuilder = new DbContextOptionsBuilder <HarmonyToysDatabaseContext>();

            optionsBuilder.UseSqlServer(constr);
            var context = new HarmonyToysDatabaseContext(optionsBuilder.Options);

            usercontroller = new UserController(context);
            controller     = new LoginController(context);
        }
예제 #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, HarmonyToysDatabaseContext context)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

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

            app.UseStaticFiles();

            // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715
            app.UseCookieAuthentication(CookieAuthenticationOptions);

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            DbInitializer.Initialize(context);
        }
예제 #3
0
 public LoginController(HarmonyToysDatabaseContext _context)
 {
     context = _context;
 }
예제 #4
0
 public UserController(HarmonyToysDatabaseContext _context)
 {
     context = _context;
 }