Exemplo n.º 1
0
 public UsersController(SpaDbContext context)
 {
     _context = context;
 }
Exemplo n.º 2
0
 public LeavesController(SpaDbContext context)
 {
     _context = context;
 }
 public UsersController(SpaDbContext context, IOptions<AppConfiguration> appSettings)
 {
   _context = context;
   _appSettings = appSettings.Value;
 }
Exemplo n.º 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, SpaDbContext context)
        {
            loggerFactory.AddConsole(this.Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            // app.UseStaticFiles();

            app.UseStaticFiles(new StaticFileOptions()
            {
                OnPrepareResponse = c => {
                    //Do not add cache to json files. We need to have new versions when we add new translations.
                    c.Context.Response.GetTypedHeaders().CacheControl = !c.Context.Request.Path.Value.Contains(".json")
                        ? new CacheControlHeaderValue()
                    {
                        MaxAge = TimeSpan.FromDays(30)      // Cache everything except json for 30 days
                    }
                        : new CacheControlHeaderValue()
                    {
                        MaxAge = TimeSpan.FromMinutes(15)      // Cache json for 15 minutes
                    };
                }
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
                    HotModuleReplacement         = true,
                    HotModuleReplacementEndpoint = "wwwroot/dist/"
                });
                app.UseSwagger();
                app.UseSwaggerUI(c => {
                    c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
                });

                // Enable middleware to serve swagger-ui (HTML, JS, CSS etc.), specifying the Swagger JSON endpoint.

                app.MapWhen(x => !x.Request.Path.Value.StartsWith("/swagger", StringComparison.OrdinalIgnoreCase), builder => {
                    builder.UseMvc(routes => {
                        routes.MapSpaFallbackRoute(
                            name: "spa-fallback",
                            defaults: new { controller = "Home", action = "Index" });
                    });
                });
            }
            else
            {
                app.UseMvc(routes => {
                    routes.MapRoute(
                        name: "default",
                        template: "{controller=Home}/{action=Index}/{id?}");

                    routes.MapRoute(
                        "Sitemap",
                        "sitemap.xml",
                        new { controller = "Home", action = "SitemapXml" });

                    routes.MapSpaFallbackRoute(
                        name: "spa-fallback",
                        defaults: new { controller = "Home", action = "Index" });
                });
                app.UseExceptionHandler("/Home/Error");
            }
        }
 public UsersController(SpaDbContext context) => this.context = context;
 public MakesController(SpaDbContext context, IMapper mapper)
 {
     this.mapper  = mapper;
     this.context = context;
 }
Exemplo n.º 7
0
 public EstimatesController(SpaDbContext context) => this.context = context;