Ejemplo n.º 1
0
 public HomeController(IConfProvider conf, DigisellerClient client)
 {
     _conf   = conf;
     _client = client;
 }
Ejemplo n.º 2
0
 public ProductController(DigisellerClient client, IConfProvider conf)
 {
     _client = client;
     _conf   = conf;
 }
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, IConfProvider conf)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseStatusCodePagesWithReExecute("/error/{0}");

            app.Use((httpContext, next) =>
            {
                const string url = "/Dashboard/Home/Install";
                if (!conf.Get <MainSettings>().Installed&& httpContext.Request.Path != url)
                {
                    Console.WriteLine("Redirected");
                    httpContext.Response.Redirect($"http://{httpContext.Request.Host}{url}");
                }
                return(next());
            });

            app.UseSession();

            // Session middleware
            app.Use((httpContext, nextMiddleware) =>
            {
                if (!httpContext.Session.Keys.Contains(SessionHelper.KeyCurrency))
                {
                    httpContext.Session.SetCurrency(Currency.RUR);
                }

                if (!httpContext.Session.Keys.Contains(SessionHelper.KeyCart))
                {
                    httpContext.Session.SetCartId(string.Empty);
                }

                return(nextMiddleware());
            });

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

            app.UseStaticFiles();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "productListPager",
                    template: "Products/Page-{page:int}",
                    defaults: new { controller = "Product", action = "Index", category = 0 }
                    );

                routes.MapRoute(
                    name: "productListCategory",
                    template: "Products/Category-{category:int}",
                    defaults: new { controller = "Product", action = "Index", page = 1 }
                    );

                routes.MapRoute(
                    name: "productListCategoryPager",
                    template: "Products/Category-{category:int}/Page-{page:int}",
                    defaults: new { controller = "Product", action = "Index" }
                    );


                routes.MapRoute(
                    name: "productListSearch",
                    template: "Products/{search}",
                    defaults: new { controller = "Product", action = "Search", page = 1 }
                    );

                routes.MapRoute(
                    name: "productListSearchPager",
                    template: "Products/{search}/Page-{page:int}",
                    defaults: new { controller = "Product", action = "Search" }
                    );

                routes.MapRoute(
                    name: "productDetails",
                    template: "Product/{id:int}",
                    defaults: new { controller = "Product", action = "Details" }
                    );

                routes.MapRoute(
                    name: "productList",
                    template: "Products/",
                    defaults: new { controller = "Product", action = "Index", category = 0 }
                    );

                routes.MapRoute(
                    name: "cartView",
                    template: "Cart/",
                    defaults: new { controller = "Cart", action = "ViewCart" }
                    );

                routes.MapRoute("areaRoute", "{area:exists}/{controller=Home}/{action=Index}/{id?}");

                routes.MapRoute(
                    name: "default",
                    template: "{controller=Product}/{action=Index}/{id?}");
            });
        }
Ejemplo n.º 4
0
 public AuthAttribute(IConfProvider conf)
 {
     _conf = conf;
 }