Ejemplo n.º 1
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var context = new RabbitDBContext();

            if (!context.AllMigrationsApplied())
            {
                context.Database.Migrate();
            }
            context.EnsureSeedData();
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            var context = new RabbitDBContext();

            if (!context.AllMigrationsApplied())
            {
                context.Database.Migrate();
            }
            context.EnsureSeedData();

            var test = context.Hunts.Include(h => h.Animals).FirstOrDefault();

            Console.WriteLine(test.PhoneNumber);
            Console.WriteLine(test.Animals.Count());
        }
Ejemplo n.º 3
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, RabbitDBContext serverContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            if (!serverContext.AllMigrationsApplied())
            {
                serverContext.Database.Migrate();
            }
            serverContext.EnsureSeedData();

            app.UseAuthentication();

            /* TODO
             * // Add external authentication middleware below. To configure them please see https://go.microsoft.com/fwlink/?LinkID=532715
             * app.UseJwtBearerAuthentication(new JwtBearerOptions
             * {
             *  AutomaticAuthenticate = true,
             *  AutomaticChallenge = true,
             *  TokenValidationParameters = new TokenValidationParameters
             *  {
             *      ValidateIssuer = true,
             *      ValidIssuer = "https://issuer.example.com",
             *
             *      ValidateAudience = true,
             *      ValidAudience = "https://yourapplication.example.com",
             *
             *      ValidateLifetime = true,
             *  }
             * });
             */

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