2017-03-18 23:52:44 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
2017-04-26 20:29:25 +02:00
|
|
|
|
using Bit.Core;
|
2017-04-26 22:13:24 +02:00
|
|
|
|
using Stripe;
|
2017-03-18 23:52:44 +01:00
|
|
|
|
|
|
|
|
|
namespace Bit.Billing
|
|
|
|
|
{
|
|
|
|
|
public class Startup
|
|
|
|
|
{
|
|
|
|
|
public Startup(IHostingEnvironment env)
|
|
|
|
|
{
|
|
|
|
|
var builder = new ConfigurationBuilder()
|
|
|
|
|
.SetBasePath(env.ContentRootPath)
|
|
|
|
|
.AddJsonFile("settings.json", optional: false, reloadOnChange: true)
|
2017-03-19 03:37:01 +01:00
|
|
|
|
.AddJsonFile($"settings.{env.EnvironmentName}.json", optional: true);
|
|
|
|
|
|
|
|
|
|
if(env.IsDevelopment())
|
|
|
|
|
{
|
|
|
|
|
builder.AddUserSecrets<Startup>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
builder.AddEnvironmentVariables();
|
|
|
|
|
|
2017-03-18 23:52:44 +01:00
|
|
|
|
Configuration = builder.Build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IConfigurationRoot Configuration { get; }
|
|
|
|
|
|
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
|
{
|
2017-04-26 20:29:25 +02:00
|
|
|
|
// Options
|
|
|
|
|
services.AddOptions();
|
|
|
|
|
|
|
|
|
|
// Settings
|
2017-04-26 22:13:24 +02:00
|
|
|
|
var globalSettings = new GlobalSettings();
|
|
|
|
|
ConfigurationBinder.Bind(Configuration.GetSection("GlobalSettings"), globalSettings);
|
|
|
|
|
services.AddSingleton(s => globalSettings);
|
2017-04-26 20:29:25 +02:00
|
|
|
|
services.Configure<BillingSettings>(Configuration.GetSection("BillingSettings"));
|
|
|
|
|
|
2017-04-26 22:13:24 +02:00
|
|
|
|
// Stripe Billing
|
|
|
|
|
StripeConfiguration.SetApiKey(globalSettings.StripeApiKey);
|
|
|
|
|
|
|
|
|
|
// Repositories
|
|
|
|
|
services.AddSqlServerRepositories();
|
|
|
|
|
|
2017-04-27 14:17:04 +02:00
|
|
|
|
// Context
|
|
|
|
|
services.AddScoped<CurrentContext>();
|
|
|
|
|
|
2017-04-26 22:13:24 +02:00
|
|
|
|
// Services
|
|
|
|
|
services.AddBaseServices();
|
|
|
|
|
services.AddDefaultServices();
|
|
|
|
|
|
|
|
|
|
// Mvc
|
2017-03-18 23:52:44 +01:00
|
|
|
|
services.AddMvc();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
|
|
|
|
{
|
|
|
|
|
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
|
|
|
|
loggerFactory.AddDebug();
|
|
|
|
|
|
|
|
|
|
app.UseMvc();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|