SHA256
- Use GuestDocument Details page to see details. - Added GuestDocument stays in details page. Other minor changes: - Updated validators to use ValueValidator base class. - Changed Snackbar settings to show them better. - Added Empty Debug page to test things. This page wont be updated in git, all test must be local-only.
92 lines
3.1 KiB
C#
92 lines
3.1 KiB
C#
using FluentValidation;
|
|
using Microsoft.AspNetCore.Localization;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using MudBlazor.Services;
|
|
using Somnia.GuestLog.Components;
|
|
using Somnia.GuestLog.Infrastructure;
|
|
using Somnia.GuestLog.Models.Configuration;
|
|
using Somnia.GuestLog.Models.DTOs;
|
|
using Somnia.GuestLog.Services;
|
|
using Somnia.GuestLog.Services.AddressQuery;
|
|
using Somnia.GuestLog.Utils;
|
|
using Somnia.GuestLog.Validators;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
var connectionStringGuestLog = builder.Configuration.GetConnectionString("DbSomniaGuestLog")
|
|
?? throw new InvalidOperationException("Connection string 'DbSomniaGuestLog' not found.");
|
|
builder.Services.AddDbContextFactory<GuestLogContext>(options =>
|
|
{
|
|
options.UseNpgsql(connectionStringGuestLog);
|
|
});
|
|
|
|
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
|
|
|
|
// Add MudBlazor services
|
|
builder.Services.AddMudServices(c =>
|
|
{
|
|
c.SnackbarConfiguration.PositionClass = MudBlazor.Defaults.Classes.Position.TopCenter;
|
|
c.SnackbarConfiguration.ShowTransitionDuration = 300;
|
|
c.SnackbarConfiguration.HideTransitionDuration = 500;
|
|
c.SnackbarConfiguration.VisibleStateDuration = 10000;
|
|
});
|
|
|
|
// Add components services to the container.
|
|
builder.Services.AddRazorComponents()
|
|
.AddInteractiveServerComponents();
|
|
|
|
builder.Services.AddLocalization();
|
|
builder.Services.AddHttpClient();
|
|
|
|
// Add Validation Services
|
|
builder.Services.AddSingleton<IValidator<GuestDocumentDTO>, GuestDocumentDTOValidator>();
|
|
builder.Services.AddSingleton<IValidator<GuestDocIdDTO>, GuestDocIdDTOValidator>();
|
|
builder.Services.AddSingleton<IValidator<StayEntryDTO>, StayEntryDTOValidator>();
|
|
|
|
// Add Services
|
|
builder.Services.AddSingleton<IGuestDocumentService, GuestDocumentService>();
|
|
builder.Services.AddSingleton<IStayEntryService, StayEntryService>();
|
|
builder.Services.AddSingleton<IDataListService, StaticDataListService>();
|
|
|
|
// Add Factories (and it's services)
|
|
builder.Services.AddFactoryDI<IAddressQueryFactory, ConfigFileAddressQueryFactory>();
|
|
|
|
// Add Options config
|
|
builder.Services.AddOptions<AddressQueryConfig>()
|
|
.Bind(builder.Configuration.GetSection(AddressQueryConfig.SectionName));
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseMigrationsEndPoint();
|
|
}
|
|
else
|
|
{
|
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
|
app.UseHsts();
|
|
}
|
|
app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true);
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseAntiforgery();
|
|
|
|
string[] supportedCultures = ["en-US", "es-ES"];
|
|
var localizationOptions = new RequestLocalizationOptions()
|
|
.SetDefaultCulture(supportedCultures[0])
|
|
.AddSupportedCultures(supportedCultures)
|
|
.AddSupportedUICultures(supportedCultures);
|
|
localizationOptions.RequestCultureProviders = [
|
|
new QueryStringRequestCultureProvider(),
|
|
new CookieRequestCultureProvider()
|
|
];
|
|
|
|
app.UseRequestLocalization(localizationOptions);
|
|
app.MapStaticAssets();
|
|
app.MapRazorComponents<App>()
|
|
.AddInteractiveServerRenderMode();
|
|
|
|
app.Run();
|