Ejemplo n.º 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();
            string buildVersion = Environment.GetEnvironmentVariable("BUILD_VERSION");

            services
            .AddControllers();
            services.AddSingleton <Microsoft.AspNetCore.Http.IHttpContextAccessor, Microsoft.AspNetCore.Http.HttpContextAccessor>();
            services.AddHttpContextAccessor();
            services.AddDbContext <DbDataContext>(options =>
                                                  options.UseSqlServer(Configuration.GetConnectionString("DbDataContext")).UseLazyLoadingProxies());
            services.AddDbContext <DbReadDataContext>(options =>
                                                      options.UseSqlServer(Configuration.GetConnectionString("DbReadDataContext")).UseLazyLoadingProxies());
            services.AddDbContext <NexusDataContext>(options =>
                                                     options.UseSqlServer(Configuration.GetConnectionString("NexusDatabase")));


            services.AddCors(o => o.AddPolicy("MyPolicy", builder =>
            {
                builder.AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader();
            }));

            services.AddSwaggerGen(c => Swagger.Gen(Configuration, c, "User"));
        }