43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
#if POSTGRES
|
|
using Events.EF.Data.Postgres;
|
|
#else
|
|
using Events.EF.Data.MSSQL;
|
|
#endif
|
|
using Events.EF.Models;
|
|
using Events.MVC.Models;
|
|
using Events.MVC.Util.Middleware;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Sieve.Services;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Services.AddControllersWithViews(options =>
|
|
options.Filters.Add<ProblemDetailsForSqlException>());
|
|
#if POSTGRES
|
|
builder.Services.AddDbContext<EventsContext>(options =>
|
|
options.UseNpgsql(builder.Configuration.GetConnectionString("EventsPostgres")));
|
|
#else
|
|
builder.Services.AddDbContext<EventsContext>(options =>
|
|
options.UseSqlServer(builder.Configuration.GetConnectionString("EventsMssql")));
|
|
#endif
|
|
builder.Services.AddScoped<ISieveProcessor, SieveProcessor>();
|
|
builder.Services.Configure<PagingSettings>(builder.Configuration.GetSection(PagingSettings.SectionName));
|
|
|
|
var app = builder.Build();
|
|
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Home/Error");
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
app.UseStaticFiles();
|
|
|
|
app.UseRouting();
|
|
|
|
app.MapDefaultControllerRoute();
|
|
|
|
app.Run();
|
|
|
|
public partial class Program;
|