Пример #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();
            services.AddDbContext <PizzaStoreDBContext>(options => options.UseSqlServer(Configuration.GetConnectionString("PizzaStoreDBContext")));

            // services.AddIdentity<ApplicationUser, IdentityRole>()
            //     .AddDefaultTokenProviders();



            services.AddTransient <OrderRepo>();
            services.AddTransient <PizzaRepo>();
            services.AddTransient <StoreRepo>();

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddScoped(sp => CartViewModel.GetCart(sp));
            services.AddMvc();
            services.AddMemoryCache();
            services.AddSession();

            services.Configure <IdentityOptions>(options =>
            {
                // Password settings
                options.Password.RequireDigit           = true;
                options.Password.RequiredLength         = 8;
                options.Password.RequireNonAlphanumeric = false;
                options.Password.RequireUppercase       = true;
                options.Password.RequireLowercase       = false;
                options.Password.RequiredUniqueChars    = 6;

                // Lockout settings
                options.Lockout.DefaultLockoutTimeSpan  = TimeSpan.FromMinutes(30);
                options.Lockout.MaxFailedAccessAttempts = 10;
                options.Lockout.AllowedForNewUsers      = true;

                // User settings
                options.User.RequireUniqueEmail = true;
            });
        }