-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathServiceConfig.cs
More file actions
42 lines (38 loc) · 1.83 KB
/
ServiceConfig.cs
File metadata and controls
42 lines (38 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using BookingSystem.AspNetFramework.Helpers;
using BookingSystem.AspNetFramework.Controllers;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging.Abstractions;
using OpenActive.Server.NET;
using System.Configuration;
using System.Web.Http;
using BookingSystem.AspNetFramework.Utils;
using OpenActive.FakeDatabase.NET;
namespace BookingSystem.AspNetFramework
{
public class ServiceConfig
{
public static void Register(HttpConfiguration config)
{
var appSettings = new AppSettings
{
ApplicationHostBaseUrl = ConfigurationManager.AppSettings["ApplicationHostBaseUrl"],
FeatureFlags = new FeatureSettings(), // use default values for all features
Payment = new PaymentSettings
{
AccountId = ConfigurationManager.AppSettings["AccountId"],
PaymentProviderId = ConfigurationManager.AppSettings["PaymentProviderId"],
TaxCalculationB2B = ConfigurationManager.AppSettings["TaxCalculationB2B"] == "true",
TaxCalculationB2C = ConfigurationManager.AppSettings["TaxCalculationB2C"] == "true",
}
};
config.Formatters.Add(new OpenBookingInputFormatter());
var services = new ServiceCollection();
services.AddTransient<DatasetSiteController>();
services.AddTransient<OpenDataController>();
services.AddTransient<OpenBookingController>();
services.AddSingleton<IBookingEngine>(sp => EngineConfig.CreateStoreBookingEngine(appSettings, new FakeBookingSystem(false, new NullLogger<FakeBookingSystem>())));
var resolver = new DependencyResolver(services.BuildServiceProvider(true));
config.DependencyResolver = resolver;
}
}
}