Beispiel #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddMvc();
            services.AddDbContext <DataContext>(options =>
                                                options.UseSqlServer(
                                                    Configuration.GetConnectionString("DefaultConnection"),
                                                    b => b.MigrationsAssembly("DbRepository")));

            services.AddIdentity <User, IdentityRole>()
            .AddEntityFrameworkStores <DataContext>();
            services.Configure <IdentityOptions>(options =>
            {
                // Default Password settings.
                options.Password.RequireDigit           = false;
                options.Password.RequireLowercase       = true;
                options.Password.RequireNonAlphanumeric = false;
                options.Password.RequireUppercase       = false;
                options.Password.RequiredLength         = 6;
                options.Password.RequiredUniqueChars    = 0;
            });


            var mapperConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MappingProfile());
            });

            services.AddSingleton(mapperConfig.CreateMapper());

            DIBuilder.ConfigureServices(services);
            DIBuilder.ConfigureRepositories(services);
        }
Beispiel #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddMvc();
            services.AddDbContext <DataContext>(options =>
                                                options.UseSqlServer(
                                                    Configuration.GetConnectionString("DefaultConnection"),
                                                    b => b.MigrationsAssembly("DbRepository")));

            services.AddIdentity <User, IdentityRole>()
            .AddEntityFrameworkStores <DataContext>();

            var mapperConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MappingProfile());
            });

            services.AddSingleton(mapperConfig.CreateMapper());

            DIBuilder.ConfigureServices(services);
            DIBuilder.ConfigureRepositories(services);
        }