diff --git a/Francesco.Recipes.World/Francesco.Recipes.World.csproj b/Francesco.Recipes.World/Francesco.Recipes.World.csproj index 3f3545e..f9e0493 100644 --- a/Francesco.Recipes.World/Francesco.Recipes.World.csproj +++ b/Francesco.Recipes.World/Francesco.Recipes.World.csproj @@ -8,7 +8,20 @@ - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -16,6 +29,9 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Francesco.Recipes.World/Program.cs b/Francesco.Recipes.World/Program.cs index 885c57a..1155aee 100644 --- a/Francesco.Recipes.World/Program.cs +++ b/Francesco.Recipes.World/Program.cs @@ -1,4 +1,26 @@ -var builder = WebApplication.CreateBuilder(args); +using Francesco.Recipes.World.Data; +using Microsoft.AspNetCore.Identity; +using Microsoft.EntityFrameworkCore; +using Serilog; + + +var builder = WebApplication.CreateBuilder(args); +var services = builder.Services; +var configuration = builder.Configuration; + +services.AddLogging( + loggingBuilder => + loggingBuilder.AddSerilog( + new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger())); + + +var connectionString = builder.Configuration.GetConnectionString("FrancescosRecipesWorldDbContextConnection") + ?? throw new InvalidOperationException("Connection string 'RecruitmentToolDbContextConnection' not found."); +services.AddDbContext(options => + options.UseSqlServer(connectionString)); + +services.AddDefaultIdentity(options => options.SignIn.RequireConfirmedAccount = true) + .AddEntityFrameworkStores(); // Add services to the container. builder.Services.AddControllersWithViews(); @@ -18,9 +40,12 @@ app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); +app.UseAuthentication(); app.UseAuthorization(); +app.MapDefaultControllerRoute(); + app.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); diff --git a/Francesco.Recipes.World/appsettings.json b/Francesco.Recipes.World/appsettings.json index 10f68b8..07a22b4 100644 --- a/Francesco.Recipes.World/appsettings.json +++ b/Francesco.Recipes.World/appsettings.json @@ -5,5 +5,42 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "ConnectionStrings": { + "FrancescosRecipesWorldDbContextConnection": "Server=localhost\\SQLEXPRESS;Database=Francesco.Recipes.World; Trusted_Connection=True; MultipleActiveResultSets=true;TrustServerCertificate=True " + }, + "EmailConfiguration": { + "Server": "127.0.0.1", + "SmtpPort": 1025, + "User": "", + "Password": "", + "EnableSsl": false, + "From": "mailhog@localhost.net", + "WebUserInterface": "127.0.0.1:8025" + }, + "Serilog": { + "MinimumLevel": { + "Default": "Debug", + "Override": { + "System": "Information", + "Microsoft": "Information" + } + }, + "WriteTo": [ + { + "Name": "Sentry", + "Args": { + "Dsn": "https://84d32207fb244762a68b9d4a5de92495@sentry.intersim.ch/8", + "MinimumBreadcrumbLevel": "Debug", + "MinimumEventLevel": "Debug" + } + } + ], + "Enrich": [ + "FromLogContext", + "WithMachineName", + "WithThreadId" + ] + } + }