diff --git a/EntityFrameworkCore.API/EntityFrameworkCore.API.csproj b/EntityFrameworkCore.API/EntityFrameworkCore.API.csproj new file mode 100644 index 0000000..4117b6a --- /dev/null +++ b/EntityFrameworkCore.API/EntityFrameworkCore.API.csproj @@ -0,0 +1,13 @@ + + + + net9.0 + enable + enable + + + + + + + diff --git a/EntityFrameworkCore.API/EntityFrameworkCore.API.http b/EntityFrameworkCore.API/EntityFrameworkCore.API.http new file mode 100644 index 0000000..fca63dd --- /dev/null +++ b/EntityFrameworkCore.API/EntityFrameworkCore.API.http @@ -0,0 +1,6 @@ +@EntityFrameworkCore.API_HostAddress = http://localhost:5072 + +GET {{EntityFrameworkCore.API_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/EntityFrameworkCore.API/Program.cs b/EntityFrameworkCore.API/Program.cs new file mode 100644 index 0000000..ee9d65d --- /dev/null +++ b/EntityFrameworkCore.API/Program.cs @@ -0,0 +1,41 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi +builder.Services.AddOpenApi(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.MapOpenApi(); +} + +app.UseHttpsRedirection(); + +var summaries = new[] +{ + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" +}; + +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.Run(); + +record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary) +{ + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); +} diff --git a/EntityFrameworkCore.API/Properties/launchSettings.json b/EntityFrameworkCore.API/Properties/launchSettings.json new file mode 100644 index 0000000..5a8171d --- /dev/null +++ b/EntityFrameworkCore.API/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:5072", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7223;http://localhost:5072", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/EntityFrameworkCore.API/appsettings.Development.json b/EntityFrameworkCore.API/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/EntityFrameworkCore.API/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/EntityFrameworkCore.API/appsettings.json b/EntityFrameworkCore.API/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/EntityFrameworkCore.API/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}