예제 #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services
            .AddMvc()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
            .AddViewLocalization();



            services.AddEntityFrameworkNpgsql()
            .AddDbContext <ApplicationContext>(delegate(DbContextOptionsBuilder opt)
            {
                opt.UseNpgsql(DbConnectionGlobals.GetConnectionString());
                // opt.EnableDetailedErrors();
                // opt.EnableSensitiveDataLogging();
            })
            .BuildServiceProvider();


            //my
            services.AddAuthorization(opts =>
            {
                opts.AddPolicy("OnlyForAdmins", policy =>
                {
                    policy.RequireClaim(ClaimTypes.Role, "admin");
                });
            });

            services.AddLocalization(options => options.ResourcesPath = "Resources");

            services.AddTransient <EmailMessageSender>();
            services.AddTransient <AccountRegistrationService>();
            services.AddTransient <BotMassMailingService>();

            services.AddSingleton <SimpleLogger>();
            services.AddSingleton <OrdersCountNotificationService>();
            services.AddSingleton <BotForSalesStatisticsService>();
            services.AddSingleton <TotalLog>();
            services.AddSingleton <DomainNameService>();
            services.AddTransient <BotsAirstripService>();


            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options =>
            {
                options.LoginPath        = new PathString("/SignIn/Login");
                options.AccessDeniedPath = new PathString("/SignIn/Login");
            });
        }
예제 #2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddEntityFrameworkNpgsql()
            .AddDbContext <ApplicationContext>(opt => opt.UseNpgsql(DbConnectionGlobals.GetConnectionString()))
            .BuildServiceProvider();

            services.AddSingleton <DbConnector>();
            services.AddSingleton <SimpleLogger>();
            services.AddSingleton <BotStatisticsSynchronizer>();
            services.AddSingleton <RouteRecordsSynchronizerService>();
        }
예제 #3
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });
            services.AddSingleton <SimpleLogger>();
            services.AddSingleton <DiagnosticService>();
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.AddEntityFrameworkNpgsql()
            .AddDbContext <ApplicationContext>(opt => opt.UseNpgsql(DbConnectionGlobals.GetConnectionString()))
            .BuildServiceProvider();

            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options =>
            {
                options.LoginPath        = new PathString("/SignIn/Login");
                options.AccessDeniedPath = new PathString("/SignIn/Login");
            });
        }