Events-MVC (example with htmx)
This commit is contained in:
42
Events-MVC/Events.MVC/Program.cs
Normal file
42
Events-MVC/Events.MVC/Program.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
#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;
|
||||
Reference in New Issue
Block a user