Пример #1
0
 public static void Initialize()
 {
     if (!testsInitialized)
     {
         AutoMapperProfile.RegisterMappings(typeof(IService).Assembly);
         testsInitialized = true;
     }
 }
Пример #2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddDbContext <PandaDbContext>(options => options
                                                   .UseSqlServer(this.Configuration.GetConnectionString("DefaultConnection")));

            services.AddIdentity <User, IdentityRole>(options =>
            {
                options.Password.RequireDigit           = false;
                options.Password.RequireLowercase       = false;
                options.Password.RequireUppercase       = false;
                options.Password.RequireNonAlphanumeric = false;
                options.User.RequireUniqueEmail         = true;
            })
            .AddDefaultUI(UIFramework.Bootstrap4)
            .AddEntityFrameworkStores <PandaDbContext>()
            .AddDefaultTokenProviders();

            services.AddAuthentication()
            .AddFacebook(facebookOptions =>
            {
                facebookOptions.AppId     = this.Configuration["Authentication:Facebook:AppId"];
                facebookOptions.AppSecret = this.Configuration["Authentication:Facebook:AppSecret"];
            })
            .AddGoogle(googleOptions =>
            {
                googleOptions.ClientId     = this.Configuration["Authentication:Google:ClientId"];
                googleOptions.ClientSecret = this.Configuration["Authentication:Google:ClientSecret"];
            });

            AutoMapperProfile.RegisterMappings(typeof(IService).Assembly);

            services.AddResponseCompression();
            services.AddDomainServices();
            services.AddAutoMapper();

            services.AddRouting(options => options.LowercaseUrls = true);

            services
            .AddMvc(options =>
            {
                options.Filters.Add <AutoValidateAntiforgeryTokenAttribute>();
            })
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }