DbGovor init

This commit is contained in:
Artemy
2025-06-16 22:31:45 +07:00
parent c7c778ceb1
commit d62c38db51
25 changed files with 613 additions and 36 deletions
+24 -25
View File
@@ -1,9 +1,28 @@
using Govor.Data;
using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
// Add services
builder.Services.AddSignalR();
builder.Services.AddControllers();
builder.Services.AddDbContext<GovorDbContext>(
options =>
{
options.UseNpgsql(builder.Configuration.GetConnectionString(nameof(GovorDbContext)));
}
);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddOpenApi();
builder.Services.AddAuthorization();
var app = builder.Build();
// Configure the HTTP request pipeline.
@@ -14,28 +33,8 @@ if (app.Environment.IsDevelopment())
app.UseHttpsRedirection();
var summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
app.UseAuthorization();
app.MapGet("/weatherforecast", () =>
{
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");
app.MapControllers();
app.Run();
record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
{
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
app.Run();