2025-08-01 15:48:20 +02:00
|
|
|
using PresentPortal.ApiService.Areas.Identity.Data;
|
|
|
|
|
|
2025-07-06 19:15:24 +02:00
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
2025-08-01 15:48:20 +02:00
|
|
|
builder.AddNpgsqlDbContext<ApplicationDbContext>("presentportal");
|
|
|
|
|
|
|
|
|
|
builder.Services
|
|
|
|
|
.AddDefaultIdentity<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true)
|
|
|
|
|
.AddEntityFrameworkStores<ApplicationDbContext>();
|
|
|
|
|
|
2025-07-06 19:15:24 +02:00
|
|
|
// Add service defaults & Aspire client integrations.
|
|
|
|
|
builder.AddServiceDefaults();
|
|
|
|
|
|
|
|
|
|
// Add services to the container.
|
|
|
|
|
builder.Services.AddProblemDetails();
|
|
|
|
|
|
|
|
|
|
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
|
|
|
|
builder.Services.AddOpenApi();
|
|
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
|
app.UseExceptionHandler();
|
|
|
|
|
|
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
|
|
|
{
|
2025-08-01 15:48:20 +02:00
|
|
|
app.MapOpenApi();
|
2025-07-06 19:15:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string[] summaries =
|
2025-08-01 15:48:20 +02:00
|
|
|
["Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"];
|
2025-07-06 19:15:24 +02:00
|
|
|
|
|
|
|
|
app.MapGet("/weatherforecast", () =>
|
2025-08-01 15:48:20 +02:00
|
|
|
{
|
|
|
|
|
var forecast = Enumerable.Range(1, 5).Select(index =>
|
|
|
|
|
new WeatherForecast
|
|
|
|
|
(
|
|
|
|
|
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
|
|
|
|
Random.Shared.Next(-20, 55),
|
|
|
|
|
summaries[Random.Shared.Next(summaries.Length)]
|
|
|
|
|
))
|
|
|
|
|
.ToArray();
|
|
|
|
|
return forecast;
|
|
|
|
|
})
|
|
|
|
|
.WithName("GetWeatherForecast");
|
2025-07-06 19:15:24 +02:00
|
|
|
|
|
|
|
|
app.MapDefaultEndpoints();
|
|
|
|
|
|
|
|
|
|
app.Run();
|
|
|
|
|
|
|
|
|
|
record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
|
|
|
|
|
{
|
2025-08-01 15:48:20 +02:00
|
|
|
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
2025-07-06 19:15:24 +02:00
|
|
|
}
|