Пример #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services
            .AddIdentity <BenchUser, IdentityRole>(cfg =>
            {
                cfg.User.RequireUniqueEmail = true;
            })
            .AddRoles <IdentityRole>()
            .AddEntityFrameworkStores <BenchContext>();

            services.AddDbContext <BenchContext>(cfg =>
            {
                string connecitonString = _config.GetConnectionString("BenchConnectionString");
                cfg.UseSqlServer(connecitonString);
            });


            services.AddTransient <BenchSeeder>();
            services.AddTransient <IAssetService, WalksService>();

            services.AddOptions();
            services.Configure <AzureStorageConfig>(_config.GetSection("AzureStorageConfig"));

            services.AddSingleton <IStorageService>(serviceProvider => {
                var blobStorage = new BlobStorageService(serviceProvider.GetService <IOptions <AzureStorageConfig> >());
                blobStorage.ConfigureBlobStorage().GetAwaiter().GetResult();
                return(blobStorage);
            });
            services.AddSingleton <ITableStorageService, TableStorageService>();

            services.AddMvc();
        }