From 967d6cd31bc91a8f783117a0bc1da5f0b13d5448 Mon Sep 17 00:00:00 2001 From: Alpha 2 <83462052+Alpha-2@users.noreply.github.com> Date: Fri, 28 Nov 2025 19:51:07 +0100 Subject: [PATCH] Add project files. --- PLacer-WebAPI.slnx | 3 ++ .../Controllers/WeatherForecastController.cs | 26 ++++++++++++++ PLacer-WebAPI/PLacer-WebAPI.csproj | 14 ++++++++ PLacer-WebAPI/PLacer-WebAPI.http | 6 ++++ PLacer-WebAPI/Program.cs | 34 +++++++++++++++++++ PLacer-WebAPI/Properties/launchSettings.json | 23 +++++++++++++ PLacer-WebAPI/WeatherForecast.cs | 13 +++++++ PLacer-WebAPI/appsettings.Development.json | 8 +++++ PLacer-WebAPI/appsettings.json | 9 +++++ 9 files changed, 136 insertions(+) create mode 100644 PLacer-WebAPI.slnx create mode 100644 PLacer-WebAPI/Controllers/WeatherForecastController.cs create mode 100644 PLacer-WebAPI/PLacer-WebAPI.csproj create mode 100644 PLacer-WebAPI/PLacer-WebAPI.http create mode 100644 PLacer-WebAPI/Program.cs create mode 100644 PLacer-WebAPI/Properties/launchSettings.json create mode 100644 PLacer-WebAPI/WeatherForecast.cs create mode 100644 PLacer-WebAPI/appsettings.Development.json create mode 100644 PLacer-WebAPI/appsettings.json diff --git a/PLacer-WebAPI.slnx b/PLacer-WebAPI.slnx new file mode 100644 index 0000000..6e6d2bd --- /dev/null +++ b/PLacer-WebAPI.slnx @@ -0,0 +1,3 @@ + + + diff --git a/PLacer-WebAPI/Controllers/WeatherForecastController.cs b/PLacer-WebAPI/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..5ca240a --- /dev/null +++ b/PLacer-WebAPI/Controllers/WeatherForecastController.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Mvc; + +namespace PLacer_WebAPI.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = + [ + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + ]; + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} diff --git a/PLacer-WebAPI/PLacer-WebAPI.csproj b/PLacer-WebAPI/PLacer-WebAPI.csproj new file mode 100644 index 0000000..e2fc636 --- /dev/null +++ b/PLacer-WebAPI/PLacer-WebAPI.csproj @@ -0,0 +1,14 @@ + + + + net10.0 + enable + enable + PLacer_WebAPI + + + + + + + diff --git a/PLacer-WebAPI/PLacer-WebAPI.http b/PLacer-WebAPI/PLacer-WebAPI.http new file mode 100644 index 0000000..93451f3 --- /dev/null +++ b/PLacer-WebAPI/PLacer-WebAPI.http @@ -0,0 +1,6 @@ +@PLacer_WebAPI_HostAddress = http://localhost:5110 + +GET {{PLacer_WebAPI_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/PLacer-WebAPI/Program.cs b/PLacer-WebAPI/Program.cs new file mode 100644 index 0000000..cc947d6 --- /dev/null +++ b/PLacer-WebAPI/Program.cs @@ -0,0 +1,34 @@ + +namespace PLacer_WebAPI +{ + public class Program + { + public static void Main(string[] args) + { + var builder = WebApplication.CreateBuilder(args); + + // Add services to the container. + + builder.Services.AddControllers(); + // 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(); + + app.UseAuthorization(); + + + app.MapControllers(); + + app.Run(); + } + } +} diff --git a/PLacer-WebAPI/Properties/launchSettings.json b/PLacer-WebAPI/Properties/launchSettings.json new file mode 100644 index 0000000..53d4e19 --- /dev/null +++ b/PLacer-WebAPI/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:5110", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7051;http://localhost:5110", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/PLacer-WebAPI/WeatherForecast.cs b/PLacer-WebAPI/WeatherForecast.cs new file mode 100644 index 0000000..e7830d9 --- /dev/null +++ b/PLacer-WebAPI/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace PLacer_WebAPI +{ + public class WeatherForecast + { + public DateOnly Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} diff --git a/PLacer-WebAPI/appsettings.Development.json b/PLacer-WebAPI/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/PLacer-WebAPI/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/PLacer-WebAPI/appsettings.json b/PLacer-WebAPI/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/PLacer-WebAPI/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}