-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
58 lines (44 loc) · 2.09 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
49
50
51
52
53
54
55
56
57
58
using fortunestreetanalyzer.DatabaseModels.fortunestreet;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
string fortuneStreetSQLConnectionString = new SqlConnectionStringBuilder
{
DataSource = "tcp:analyzerprojects-secretply.database.windows.net,1433",
InitialCatalog = "fortunestreet",
Authentication = SqlAuthenticationMethod.ActiveDirectoryDefault,
CommandTimeout = (int) TimeSpan.FromMinutes(5).TotalSeconds
}.ConnectionString;
#if DEBUG
fortuneStreetSQLConnectionString = new SqlConnectionStringBuilder
{
DataSource = "tcp:analyzerprojects-secretply.database.windows.net,1433",
InitialCatalog = "fortunestreet",
UserID = builder.Configuration["AZURE-SQLSERVER-ANALYZERPROJECTS-SECRETPLY-FORTUNESTREET-USERNAME"],
Password = builder.Configuration["AZURE-SQLSERVER-ANALYZERPROJECTS-SECRETPLY-FORTUNESTREET-PASSWORD"],
CommandTimeout = (int) TimeSpan.FromMinutes(5).TotalSeconds
}.ConnectionString;
#endif
builder.Services.AddDbContext<FortuneStreetAppContext>(options => options.UseSqlServer(new SqlConnection(fortuneStreetSQLConnectionString)));
builder.Services.AddDbContext<FortuneStreetSavePreRollContext>(options => options.UseSqlServer(new SqlConnection(fortuneStreetSQLConnectionString)));
builder.Services.AddDbContext<FortuneStreetSavePostRollContext>(options => options.UseSqlServer(new SqlConnection(fortuneStreetSQLConnectionString)));
builder.Services.AddMvc().AddRazorPagesOptions(options =>
{
options.Conventions.ConfigureFilter(new IgnoreAntiforgeryTokenAttribute());
});
builder.Services.AddMvc().AddJsonOptions(options =>
{
options.JsonSerializerOptions.PropertyNamingPolicy = null;
});
WebApplication app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
app.UseExceptionHandler("/Error");
app.UseFileServer();
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.Run();