-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathProgram.cs
48 lines (36 loc) · 1.19 KB
/
Program.cs
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
43
44
45
46
47
48
using BadgeMeUp;
using BadgeMeUp.Db;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddScoped<BadgeContext, BadgeContext>();
builder.Services.AddScoped<BadgeDb, BadgeDb>();
builder.Services.AddScoped<UserDb, UserDb>();
builder.Services.AddScoped<EmailQueueDb, EmailQueueDb>();
builder.Services.AddScoped<BadgeImageDb, BadgeImageDb>();
builder.Services.AddHttpContextAccessor();
#if DEBUG == true
builder.Services.AddScoped<ICurrentUserInfo, MockCurrentUser>();
#else
builder.Services.AddScoped<BadgeMeUp.ICurrentUserInfo, BadgeMeUp.AppServiceCurrentUser>();
#endif
var app = builder.Build();
// Configure the HTTP request pipeline.
if(!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
//app.UseAuthorization();
app.MapRazorPages();
IConfiguration config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", false)
.AddEnvironmentVariables()
.Build();
var dbContext = new BadgeContext(config);
dbContext.Initialize();
app.Run();