// 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,
                              WorldContextSeedData seeder,
                              ILoggerFactory factory)
        {
            Mapper.Initialize(config =>
            {
                config.CreateMap <TripViewModel, Trip>().ReverseMap();
                config.CreateMap <StopViewModel, Stop>().ReverseMap();
            });

            if (env.IsEnvironment("Development"))
            {
                app.UseDeveloperExceptionPage();
                factory.AddDebug(LogLevel.Information);
            }
            else
            {
                factory.AddDebug(LogLevel.Error);
            }

            //app.UseDefaultFiles();
            app.UseStaticFiles();

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" });
            });

            seeder.EnsureSeedData().Wait();
        }
Beispiel #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,
                              WorldContextSeedData seeder, ILoggerFactory loggerFactory)
        {
            // This code is called EVERY TIME a request is made. Equivalent of express middleware concept.
            loggerFactory.AddConsole();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // Order of declarations is important
            app.UseDefaultFiles();
            app.UseStaticFiles();
            app.UseMvc(config => {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" });
            });

            Mapper.Initialize(config =>
            {
                config.CreateMap <ViewModels.Trip, Models.Trip>().ReverseMap();
            });

            seeder.EnsureSeedData().Wait();
        }
Beispiel #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public async void Configure(IApplicationBuilder app,
                                    IHostingEnvironment env,
                                    WorldContextSeedData seeder,
                                    ILoggerFactory loggerFactory)
        {
            if (env.IsEnvironment("Development"))
            {
                app.UseDeveloperExceptionPage();
                loggerFactory.AddDebug(LogLevel.Information);
            }
            else
            {
                loggerFactory.AddDebug(LogLevel.Error);
            }

            app.UseStaticFiles();

            app.UseIdentity();

            Mapper.Initialize(config =>
            {
                config.CreateMap <TripViewModel, Trip>().ReverseMap();
                config.CreateMap <StopViewModel, Stop>().ReverseMap();
            });

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller=App}/{action=Index}/{id?}"
                    );
            });

            await seeder.EnsureSeedData();
        }
Beispiel #4
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,
                              WorldContextSeedData seeder, ILoggerFactory factory)
        {
            loggerFactory.AddConsole();

            if (env.IsDevelopment())
            {
                TelemetryConfiguration.Active.DisableTelemetry = true;
                app.UseDeveloperExceptionPage();
                factory.AddDebug(LogLevel.Information);
            }
            else
            {
                factory.AddDebug(LogLevel.Error);
            }

            app.UseStaticFiles();
            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" }
                    );
            });

            seeder.EnsureSeedData().Wait();
        }
Beispiel #5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public async void Configure(IApplicationBuilder app, WorldContextSeedData seederWorld, ProfileMakerContextSeedData seederProfileMaker, ILoggerFactory loggerFactory)
        {
            //Order of this - importent!!

            loggerFactory.AddDebug(LogLevel.Warning);

            app.UseStaticFiles();

            app.UseIdentity();

            Mapper.Initialize(config =>
            {
                //world
                config.CreateMap <Trip, TripViewModel>().ReverseMap();
                config.CreateMap <Stop, StopViewModel>().ReverseMap();

                //ProfileMaker
                config.CreateMap <ProfileUser, ProfileUserViewModel>().ReverseMap();
                config.CreateMap <OtherCourse, OtherCourseViewModel>().ReverseMap();
            });

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" }
                    );
            });

            seederWorld.EnsureSeedData();
            await seederProfileMaker.EnsureSeedDataAsync();
        }
Beispiel #6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

        public void Configure(IApplicationBuilder app, IHostingEnvironment env,
                              WorldContextSeedData seeder)                                                                                  //, ILoggerFactory factory)
        {
            //Mapper.Initialize(config =>
            //{

            //});

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                //factory.AddDebug(LogLevel.Information);
            }
            else
            {
                //factory.AddDebug(LogLevel.Error);
            }
            app.UseStaticFiles();
            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" }
                    );
            });

            seeder.EnsureSeedData().Wait();
        }
Beispiel #7
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public async void Configure(IApplicationBuilder app, WorldContextSeedData wcsd, ILoggerFactory loggerFactory)
        {
            //you could add provider to log to a db
            loggerFactory.AddDebug(LogLevel.Warning);

            app.UseStaticFiles();

            app.UseIdentity();

            AutoMapper.Mapper.Initialize(config =>
            {
                //map both way through anon method
                config.CreateMap <Trip, TripViewModel>().ReverseMap();
                config.CreateMap <Stop, StopViewModel>().ReverseMap();
            });

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "index" }
                    );
            });
            //used code first migrations
            await wcsd.EnsureSeedData();
        }
Beispiel #8
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, WorldContextSeedData seeder)
        {
            Mapper.Initialize(config =>
            {
                config.CreateMap <TripViewModel, Trip>().ReverseMap();
                config.CreateMap <StopViewModel, Stop>().ReverseMap();
            });

            if (_env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                loggerFactory.AddConsole(LogLevel.Information);
            }
            else
            {
                loggerFactory.AddConsole(LogLevel.Information);
            }

            app.UseStaticFiles();
            app.UseIdentity();

            app.UseMvc(config => {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" }
                    );
            });

            seeder.EnsureSeedData().Wait();
        }
Beispiel #9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, WorldContextSeedData seeder)
        {
            //app.UseDefaultFiles(); -> index.html will be handled by MVC, so we remove this form here;

            Mapper.Initialize(config =>
            {
                config.CreateMap <TripViewModel, Trip>().ReverseMap();
            });

            app.UseStaticFiles();

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",//App/Index/ id is not necessary
                    defaults: new { controller = "App", action = "Index" } //anonyous object
                    );
            }
                       );

            seeder.EnsureSeedData();

            /*app.Run(async (context) =>
             * {
             *  await context.Response.WriteAsync($"Hello World!: {context.Request.Path}"); //$ {} IS C# 6 feature
             * });*/
        }
Beispiel #10
0
        public void Configure(IApplicationBuilder app, WorldContextSeedData seeder, ILoggerFactory factory)
        {
            if (_env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                factory.AddDebug(LogLevel.Information);
            }
            else
            {
                factory.AddDebug(LogLevel.Error);
            }

            //app.UseNodeModules(_env.ContentRootPath);

            app.UseMvc(config =>
            {
                config.MapRoute(name: "Default",
                                template: "{controller}/{action}/{id?}",
                                defaults: new { controller = "App", action = "Index" });
            });

            //app.UseFileServer();

            seeder.EnsureSeedData().Wait();
        }
Beispiel #11
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, WorldContextSeedData seeder, ILoggerFactory factory)
        {
            app.UseStaticFiles();

            app.UseIdentity();

            Mapper.Initialize(config => {
                config.CreateMap <TripViewModel, Trip>().ReverseMap();
                config.CreateMap <StopViewModel, Stop>().ReverseMap();
            });

            // Check if client is a development-machine to show stacktraces etc.
            if (_env.IsEnvironment("Development"))
            {
                app.UseDeveloperExceptionPage();
                factory.AddDebug(LogLevel.Information);
            }
            else
            {
                factory.AddDebug(LogLevel.Error);
            }


            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" }
                    );
            });
            seeder.EnsureSeedData().Wait();
        }
Beispiel #12
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 factory,
                              WorldContextSeedData seeder)
        {
            factory.AddConsole();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                factory.AddDebug(LogLevel.Information);
            }
            else
            {
                factory.AddDebug(LogLevel.Error);
            }
            //UseDefaultFiles allows the static file to be the default page
            app.UseStaticFiles();

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" }
                    );
            });

            seeder.EnsureSeedData().Wait();
        }
Beispiel #13
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.   IHostingEnvironment env, ILoggerFactory loggerFactory
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              WorldContextSeedData seeder,
                              ILoggerFactory logFactory)
        {
            //Initialize Mapper
            Mapper.Initialize(config =>
            {
                //Create TripVM -> Trip and reverse map Trip -> TripVM
                config.CreateMap <TripViewModel, Trip>().ReverseMap();
                config.CreateMap <StopViewModel, Stop>().ReverseMap();
            }
                              );

            if (env.IsEnvironment("Development"))
            {
                //Allows to see
                app.UseDeveloperExceptionPage();


                //Microsoft.Extensions.Logging
                logFactory.AddDebug(LogLevel.Information);
            }
            else
            {
                logFactory.AddDebug(LogLevel.Error);
            }

            //Add MiddleWare -> to serve files to the browser
            app.UseStaticFiles();

            //What routes belong to which controllers
            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" }
                    );
            }
                       );

            // TRICK! - Configure() can not be async, so that's why async EnsureSeedData() has .Wait()
            seeder.EnsureSeedData().Wait();



            //loggerFactory.AddConsole();

            //if (env.IsDevelopment())
            //{
            //    app.UseDeveloperExceptionPage();
            //}

            //app.Run(async (context) =>
            //{
            //    await context.Response.WriteAsync("<html><body><h2>Hello World!</h2></body></html>");
            //});
        }
        /// <summary>
        /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        /// This is where the middle-ware is applied.  Order matters.
        /// </summary>
        /// <param name="app"><see cref="IApplicationBuilder"/> </param>
        /// <param name="env"><see cref="IHostingEnvironment"/></param>
        /// <param name="loggerFactory"><see cref="ILoggerFactory"/></param>
        /// <param name="seeder"><see cref="WorldContextSeedData"/></param>
        /// <param name="logFactory"><see cref="ILoggerFactory"/></param>
        public void Configure(IApplicationBuilder app, IHostingEnvironment env,
                              ILoggerFactory loggerFactory, WorldContextSeedData seeder, ILoggerFactory logFactory)
        {
            loggerFactory.AddConsole();

            // Middle-ware
            //app.UseDefaultFiles();  // Should be first when using just static files.

            // For debugging:
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                logFactory.AddDebug(LogLevel.Information);
            }
            else
            {
                logFactory.AddDebug(LogLevel.Error);
            }


            Mapper.Initialize(config =>
            {
                // We create a map from TripViewModels to Trip and Trip to TripViewModels with ReverseMap call.
                // Will also create mappings for collections of these types.
                config.CreateMap <TripViewModels, Trip>().ReverseMap();
                config.CreateMap <StopViewModel, Stop>().ReverseMap();
            });

            app.UseStaticFiles();

            // Turn on use of ASP.NET Identity
            app.UseIdentity();

            // Typically one of the last items to configure.
            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" }
                    );
            });

            // Force synchronous call with Wait();
            seeder.EnsureSeedData().Wait();

            //if (env.IsDevelopment())
            //{
            //    app.UseDeveloperExceptionPage();
            //}

            //app.Run(async (context) =>
            //{
            //    await context.Response.WriteAsync("Hello World!");
            //});
        }
Beispiel #15
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 factory
                              , WorldContextSeedData seeder)
        {
            // loggerFactory.AddConsole();
            //  if(env.IsEnvironment("Development"))

            Mapper.Initialize(config =>
            {
                config.CreateMap <TripViewModel, Trip>().ReverseMap();
                config.CreateMap <StopViewModel, Stop>().ReverseMap();
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                factory.AddDebug(LogLevel.Information);
            }
            else
            {
                factory.AddDebug(LogLevel.Error);
            }
            //  app.UseDefaultFiles();
            app.UseStaticFiles();

            app.UseIdentity();


            //  app.UseMvc(config =>
            //  {
            //  config.MapRoute(
            //   name:"Default",
            //   template:"{controller}/{action}/{id?}",
            //   defaults: new {controller="App",action="Index"}
            //  );
            //  });

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" }
                    );
            });

            // Info:Make the async wait to complete -- like sync.
            seeder.EnsureSeedData().Wait();


            // app.Run(async (context) =>
            // {
            //     await context.Response.WriteAsync("Hello World!");
            // });
        }
Beispiel #16
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        // This code gets written and called every time a request comes in. Aka Middleware in other frameworks
        // Configure sets up what sort of code is going to handle requests as they come in
        // Every part of the web server is optional. Including simple cases like serving static files
        // Entire set of operations. Nothing is hidden or implicit. Replaces the global.asax. ORDER IS IMPORTANT
        // Interface IHostingEnvironment is provided by the system. Works more broadly than C#: #if DEBUG

        // List of things (middlewares) that are going to look at requests and possibly return responses
        // Must enable the dependancy. Enabled in project.json.
        // MUST be in correct order (ie default file before static files)
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              ILoggerFactory factory,
                              WorldContextSeedData seeder)
        {
            // lets errors go to output console
            factory.AddConsole();

            // protect exceptions details from non-dev machines. Knows a Dev machine by project properties.
            // to change environment -- Props --> Debug --> Environment variables --> Value
            if (env.IsEnvironment("Development"))   // also set w/ env.IsEnvironment("Development")...

            {
                app.UseDeveloperExceptionPage();
                factory.AddDebug(LogLevel.Information);  // this log level is more verbose
            }
            else
            {
                factory.AddDebug(LogLevel.Error);
            }

            app.UseStaticFiles();

            // Tell our app to use EF Identity. This turns it "on" in our system
            app.UseIdentity();

            // Initialize Tries to match all field name of a source(model) and destination(return real object). creatmap does this on our config obj
            Mapper.Initialize(config =>
            {
                // Bi-directional mapping Reverse to do Entity to Model for safe return of ViewModel to API (after DB calls)
                config.CreateMap <TripViewModel, Trip>().ReverseMap();
                config.CreateMap <StopViewModel, Stop>().ReverseMap();
            });


            // Enable MVC 6: Opt into MVC 6. Need middleware to listen for specific routes that I am going to implement
            // MVC requires a numer of services, classes etc., so you must add services.AddMvc() to ConfigureServices
            // Need a way to tell which controller. Using a lambda
            app.UseMvc(config =>
            {
                // MapRoute method takes a pattern of URL witrh different options and map them to specific controllers
                config.MapRoute(
                    // Default Fallback route when no specific route is being used for a specific method
                    // here using a C# construct to see the different parts ie name: ckjgshjkg
                    name: "Default",
                    template: "{controller}/{action}/{id?}", // assume parts of the route. ? at end = optional part
                                                             // Default: Root path mapped dire3ctly to the Index method on the AppController in case nothing supplied
                    defaults: new { controller = "App", action = "Index" }  // defaults if nothing supplied Look for App and Index if not specified
                    );
            });

            // Can't make Congigure() an async call - becomes a synchronous
            // Trick is to use wait
            seeder.EnsureSeedData().Wait();
        }
Beispiel #17
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, WorldContextSeedData seeder, ILoggerFactory loggerFactory)
        {
            #region default code
            //loggerFactory.AddConsole();

            //if (env.IsDevelopment())
            //{
            //    app.UseDeveloperExceptionPage();
            //}

            //app.Run(async (context) =>
            //{
            //    await context.Response.WriteAsync("Hello World!");
            //});
            #endregion default code

            if (!env.IsProduction())
            {
                app.UseDeveloperExceptionPage();
                loggerFactory.AddDebug(LogLevel.Information);
            }
            else
            {
                loggerFactory.AddDebug(LogLevel.Error);
            }

            //app.UseDefaultFiles();

            app.UseStaticFiles();

            app.UseIdentity();

            Mapper.Initialize(config =>
            {
                config.CreateMap <TripViewModel, Trip> ().ReverseMap();
                config.CreateMap <StopViewModel, Stop> ().ReverseMap();
            });

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new
                {
                    controller = "App",
                    action     = "Index"
                }
                    );
            });

            seeder.EnsureSeedData().Wait();
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              WorldContextSeedData seeder,
                              ILoggerFactory factory)
        {
            //app.UseDefaultFiles (); //Feeds index.html into UseStaticFiles call
            app.UseStaticFiles();  //These two don't work in reverse

            Mapper.Initialize(config =>
            {
                config.CreateMap <TripViewModel, Trip> ().ReverseMap();
                config.CreateMap <StopViewModel, Stop> ().ReverseMap();
            });

            if (env.IsEnvironment("Development") || env.IsEnvironment("Testing") ||
                env.IsEnvironment("RemoteDev"))
            {
                app.UseDeveloperExceptionPage();
                factory.AddDebug(LogLevel.Information);
            }
            else
            {
                factory.AddDebug(LogLevel.Error);
            }

            try
            {
                using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory> ()
                                          .CreateScope())
                {
                    serviceScope.ServiceProvider.GetService <WorldContext> ()
                    .Database.EnsureCreated();
                }
            }
            catch (Exception e)
            {
                var msg        = e.Message;
                var stacktrace = e.StackTrace;
            }

            app.UseAuthentication();

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}", //id? doesn't have to exist
                    defaults: new { controller = "App", action = "Index" }  //action = "Index"; to specify which method
                    );
            });

            seeder.EnsureSeedData().Wait();
        }
Beispiel #19
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, WorldContextSeedData seeder, ILoggerFactory factory)
        {
            //#if DEBUG
            //app.UseDeveloperExceptionPage();
            //#endif

            //AutoMapper.Mapper.Configuration.CreateMapper<>

            Mapper.Initialize(config =>
            {
                config.CreateMap <TripViewModel, Trip>().ReverseMap();
                config.CreateMap <StopViewModel, Stop>().ReverseMap();
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                factory.AddDebug(LogLevel.Information);
            }
            else
            {
                factory.AddDebug(LogLevel.Error);
            }


            // A ordem faz diferença pois se trata da execução da Middleware.

            // É isso aqui que faz utilizar o wwwroot ou as Views do ASP.Net
            //app.UseDefaultFiles();

            app.UseStaticFiles();

            // A ordem importa!
            //app.UseIdentity(); // TODO: deprecated

            AuthAppBuilderExtensions.UseAuthentication(app);

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" }
                    );
            });

            seeder.EnsureSeedData().Wait();

            //app.Run(async (context) =>
            //{
            //    await context.Response.WriteAsync("Hello World!");
            //});
        }
Beispiel #20
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,
                              WorldContextSeedData seeder, ILoggerFactory factory)
        {
            // Initialize AutoMapper for TripsController
            Mapper.Initialize(config =>
            {
                // This configuration also works for collection of Trips and TripViewModels as well!
                config.CreateMap <TripViewModel, Trip>().ReverseMap(); // <- ReverseMap allows both map directions!
                config.CreateMap <StopViewModel, Stop>().ReverseMap();
            });

            loggerFactory.AddConsole();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();

                // Add debug logging
                factory.AddDebug(LogLevel.Information);
            }
            else
            {
                // Add debug logging
                factory.AddDebug(LogLevel.Error);
            }

            //app.Run(async (context) =>
            //{
            //    await context.Response.WriteAsync("<html><body><h3>Hello World!</h3></body></html>");
            //});

            // Using default file mapping and using static files
            //app.UseDefaultFiles();
            app.UseStaticFiles();

            // Turn on Identity
            app.UseIdentity();

            // Now using MVC
            app.UseMvc(config => {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" });
            });

            // Seed the database data if needed
            seeder.EnsureSeedData().Wait();
        }
Beispiel #21
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, WorldContextSeedData seeder, ILoggerFactory loggerFactory)
 {
     loggerFactory.AddDebug(LogLevel.Information);
     app.UseDeveloperExceptionPage();
     app.UseStaticFiles();
     app.UseMvc(config =>
     {
         config.MapRoute(
             name: "Default",
             template: "{controller}/{action}/{id?}",
             defaults: new { controller = "Home", action = "Index" }
             );
     });
     seeder.EnsureSeedData();
 }
        // 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, WorldContextSeedData seeder, ILoggerFactory factory)
        {
            // Configuring AutoMapper mapping
            Mapper.Initialize(config =>
            {
                config.CreateMap <TripViewModel, Trip>().ReverseMap();
                config.CreateMap <StopViewModel, Stop>().ReverseMap();
            });

            // Error page. For debugging
            if (env.IsEnvironment("Development"))
            {
                app.UseDeveloperExceptionPage();
                // Note: AddDebug is part of Microsoft.Extensions.Logging.Debug
                factory.AddDebug(LogLevel.Information);
            }
            else
            {
                factory.AddDebug(LogLevel.Error);
            }

            // Returning HTML content
            //app.Run(async (context) =>
            //{
            //    await context.Response.WriteAsync("<html><body><h3>Hello World!</h3></body></html>");
            //});

            // Using static files (Microsoft.AspNetCore.StaticFiles)
            //app.UseDefaultFiles();
            app.UseStaticFiles();


            // Use ASP .Net Core Identity
            app.UseIdentity();

            // Using MVC (Microsoft.AspNetCore.Mvc)
            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" });
            });

            // Seed the database
            seeder.EnsureSeedData().Wait();
        }
Beispiel #23
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,
                              WorldContextSeedData seeder,
                              ILoggerFactory factory)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                factory.AddDebug(LogLevel.Information);
            }
            else
            {
                // app.UseExceptionHandler(new ExceptionHandlerOptions
                // {
                //     ExceptionHandler = context => context.Response.WriteAsync("Oops!")
                // });
                factory.AddDebug(LogLevel.Error);
            }

            app.UseFileServer();

            app.UseIdentity();

            Mapper.Initialize(config =>
            {
                config.CreateMap <TripViewModel, Trip>().ReverseMap();
                config.CreateMap <StopViewModel, Stop>().ReverseMap();
            });

            app.UseNodeModules(env.ContentRootPath);
            app.UseBowerComponents(env.ContentRootPath);

            // app.UseMvc(config =>
            // {
            //     config.MapRoute(
            //         name: "Default",
            //         template: "{controller}/{action}/{id?}",
            //         defaults: new { controller = "App", action = "Index" }
            //     );
            // });
            app.UseMvc(configureRoutes);

            seeder.EnsureSeedData().Wait();
        }
Beispiel #24
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,
                              WorldContextSeedData seeder,
                              ILoggerFactory factory)
        {
            Mapper.Initialize(config =>
            {
                config.CreateMap <TripViewModel, Trip>().ReverseMap();
                config.CreateMap <StopViewModel, Stop>().ReverseMap();
            });

            //Used to see errors, would only apply to development machines
            //You can set what the machine is in the project properties/debug
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                factory.AddDebug(LogLevel.Information);
            }
            else
            {
                factory.AddDebug(LogLevel.Error);
            }
            //ATTENTION -  Reverse order will fail. Default files sets project to look for default files
            //Use static files tells web app to serve static files. Calling in reverse results in no
            //default files found by UseStaticFiles
            //app.UseDefaultFiles();
            //Need to add a package. Check project.json for
            //"Microsoft.AspNetCore.StaticFiles": "1.0.0"
            app.UseStaticFiles();

            app.UseMvc(config =>
            {
                //Can be written like a regular method, this makes it more readable
                config.MapRoute(
                    name: "Default",
                    //Note ID is optional
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" }
                    );
            });

            seeder.EnsureSeedData().Wait();
        }
Beispiel #25
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,
                              WorldContextSeedData seeder)
        {
            loggerFactory.AddDebug(LogLevel.Information);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/error");
            }

            app.UseStaticFiles();

            //app.UseCookieAuthentication(new CookieAuthenticationOptions
            //{
            //    LoginPath = new Microsoft.AspNetCore.Http.PathString("/Auth/Login"),
            //    AutomaticChallenge = true,

            //});

            app.UseIdentity();

            Mapper.Initialize(config =>
            {
                config.CreateMap <TripViewModel, Trip>().ReverseMap();
                config.CreateMap <StopViewModel, Stop>().ReverseMap();
            });

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{Controller}/{Action}/{id?}",
                    defaults: new { controller = "App", action = "Index" }
                    );
            });

            seeder.EnsureSeedData().Wait();
        }
Beispiel #26
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,
                              WorldContextSeedData seeder)
        {
            // Map the ViewModels to their respective objects
            // ReverseMap lets you go the opposite way Trip -> TripViewModel
            Mapper.Initialize(config =>
            {
                config.CreateMap <TripViewModel, Trip>().ReverseMap();
                config.CreateMap <StopViewModel, Stop>().ReverseMap();
            });

            // Checks to make sure this is a developement machine (check using alt+enter
            // If so then we can show the exception page which is easier to debug
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                loggerFactory.AddDebug(LogLevel.Information);
            }
            else
            {
                loggerFactory.AddDebug(LogLevel.Error);
            }

            // Changes the default files request
            //app.UseDefaultFiles();
            // Static files finds the files
            app.UseStaticFiles();

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" }
                    );
            });

            // Calls the seeder.
            // Since Configure is not asynchronusneed to use the Wait command to make it act asynchronus
            // Will wait until it gets a return
            seeder.EnsureSeedData().Wait();
        }
Beispiel #27
0
        //IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              ILoggerFactory loggerFactory,
                              WorldContextSeedData seeder)
        {
            //loggerFactory.AddConsole();

            Mapper.Initialize(config =>
            {
                config.CreateMap <TripViewModel, Trip>().ReverseMap();
                config.CreateMap <StopViewModel, Stop>().ReverseMap();
            });

            if (_env.IsEnvironment("Development"))
            {
                app.UseDeveloperExceptionPage();
                loggerFactory.AddDebug(LogLevel.Information);
            }
            else
            {
                loggerFactory.AddDebug(LogLevel.Debug);
            }


            app.UseStaticFiles();

            app.UseIdentity();

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" }
                    );
            });

            //app.Run(async (context) =>
            //{
            //    await context.Response.WriteAsync("<html><body>Hello World!</body></html>");
            //});

            seeder.EnsureSeedData().Wait();
        }
Beispiel #28
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, WorldContextSeedData seeder, ILoggerFactory factory)
        {
            Mapper.Initialize(config =>
            {
                config.CreateMap <TripViewModel, Trip>().ForMember(dest => dest.DateCreated,
                                                                   opt => opt.MapFrom(src => src.Created)).ReverseMap();
                config.CreateMap <StopViewModel, Stop>().ReverseMap();

                config.CreateMap <CreateUserViewModel, User>()
                .ForMember(d => d.IsNotificationsAllowed, opt => opt.MapFrom(src => src.AllowNotifications))
                .ForMember(d => d.PhoneNumber, opt => opt.MapFrom(src => src.Phone))
                .ReverseMap();

                config.CreateMap <UserInfoViewModel, User>()
                .ForMember(d => d.IsNotificationsAllowed, opt => opt.MapFrom(src => src.AllowNotifications))
                .ForMember(d => d.PhoneNumber, opt => opt.MapFrom(src => src.Phone)).ReverseMap();
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                factory.AddDebug(LogLevel.Information);
            }
            else
            {
                factory.AddDebug(LogLevel.Error);
            }

            app.UseAuthentication();
            app.UseStaticFiles();
            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" }
                    );
            });
            seeder.SeedUsers().Wait();
            seeder.EnsureSeedData().Wait();
        }
Beispiel #29
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, WorldContextSeedData seeder, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddDebug(LogLevel.Warning);

            app.UseStaticFiles();

            Mapper.Initialize(config =>
            {
                config.CreateMap <Trip, TripViewModel>().ReverseMap();
            });

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" }
                    );
            });

            seeder.EnsureSeedData();
        }
Beispiel #30
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, WorldContextSeedData seeder)
        {
            Mapper.Initialize(config =>
            {
                config.CreateMap <TripViewModel, Trip>().ReverseMap(); // o reverse map permite criar um viewmodel atraves de uma trip existente...
                config.CreateMap <StopViewModel, Stop>().ReverseMap();
            });
            loggerFactory.AddConsole();

            if (env.IsDevelopment())
            {
                loggerFactory.AddDebug(LogLevel.Information);
                app.UseDeveloperExceptionPage(); //injeta a funcao de mostrar a lista de erros na tela
            }
            else
            {
                loggerFactory.AddDebug(LogLevel.Error);
            }

            app.UseStaticFiles();

            app.UseIdentity(); //após configurar la em cima, aqui pedimos ao sistema para usar o serviço

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" }
                    );
            });
            seeder.EnsureSeedData().Wait();

            //app.UseDefaultFiles();
            //app.Run(async (context) =>
            //{
            //    await context.Response.WriteAsync("Hello World!");
            //});
        }
Beispiel #31
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, WorldContextSeedData seeder, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddDebug(LogLevel.Warning);

            app.UseStaticFiles();

            Mapper.Initialize(config =>
            {
                config.CreateMap<Trip, TripViewModel>().ReverseMap();
                config.CreateMap<Stop, StopViewModel>().ReverseMap();
            });

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new {controller = "App", action = "Index"}
                    );
            });

            seeder.EnsureSeedData();
        }