예제 #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicaitonDbContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

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

            // Create or update the database and apply migrations.
            context.Database.Migrate();

            // Add a book and review or two as sample/test data.
            SeedData.Seed(context);
        }
 //using dependency injeciton
 public CreateModel(ApplicaitonDbContext db)
 {
     _db = db;
 }
예제 #3
0
 public Repository(ApplicaitonDbContext appDbContext)
 {
     context = appDbContext;
 }
예제 #4
0
 //using dependency injeciton
 public IndexModel(ApplicaitonDbContext db)
 {
     _db = db;
 }