示例#1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.Configure <IdentityOptions>(options =>
            {
                // User settings.
                options.User.RequireUniqueEmail        = true;
                options.User.AllowedUserNameCharacters =
                    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@";

                // Password settings.
                options.Password.RequireDigit           = true;
                options.Password.RequireLowercase       = true;
                options.Password.RequireNonAlphanumeric = true;
                options.Password.RequireUppercase       = true;
                options.Password.RequiredLength         = 9;

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

            //services.AddDbContext<ApplicationDbContext>(options =>
            //    options.UseSqlServer(
            //        Configuration.GetConnectionString("DefaultConnection")));
            //services.AddDefaultIdentity<IdentityUser>()
            //    .AddEntityFrameworkStores<ApplicationDbContext>();

            services.AddDbContext <DotnetP5AppContext>(options =>
                                                       options.UseSqlServer(
                                                           Configuration.GetConnectionString("DefaultConnection")));
            services.AddDefaultIdentity <SecureAppUser>()
            .AddEntityFrameworkStores <DotnetP5AppContext>();

            //services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
            services.AddRazorPages();

            //services.AddDbContext<CarDBContext>(options => options.UseInMemoryDatabase());
            ContainerConfig.RegisterContainer();
            services.AddDbContext <CarDBContext>(options =>
                                                 options.UseSqlServer(
                                                     Configuration.GetConnectionString("DefaultConnection")));
            services.AddTransient <ICarRepository, CarRepository>();
            services.AddTransient <IRepairCarRepository, RepairCarRepository>();
            services.AddTransient <IInventoryRepository, InventoryRepository>();
        }
示例#2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(
                                                             Configuration.GetConnectionString("DefaultConnection")));
            services.AddDefaultIdentity <IdentityUser>()
            .AddEntityFrameworkStores <ApplicationDbContext>();

            //services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
            services.AddRazorPages();
            services.AddScoped <ICarData, SqlCarData>();
            ContainerConfig.RegisterContainer();
            //services.AddDbContext<CarDBContext>(options => options.UseInMemoryDatabase());
            services.AddDbContext <CarDBContext>(options =>
                                                 options.UseSqlServer(
                                                     Configuration.GetConnectionString("DefaultConnection")));
        }