diff --git a/backend/API/API.csproj b/backend/API/API.csproj new file mode 100644 index 0000000..9daa180 --- /dev/null +++ b/backend/API/API.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/backend/API/API.csproj.user b/backend/API/API.csproj.user new file mode 100644 index 0000000..9ff5820 --- /dev/null +++ b/backend/API/API.csproj.user @@ -0,0 +1,6 @@ + + + + https + + \ No newline at end of file diff --git a/backend/API/API.http b/backend/API/API.http new file mode 100644 index 0000000..995d649 --- /dev/null +++ b/backend/API/API.http @@ -0,0 +1,6 @@ +@API_HostAddress = http://localhost:5218 + +GET {{API_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/backend/API/API.sln b/backend/API/API.sln new file mode 100644 index 0000000..274ad64 --- /dev/null +++ b/backend/API/API.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34607.119 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API", "API.csproj", "{2BAE2439-DB76-4DCA-AE1F-E4194AE2E051}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2BAE2439-DB76-4DCA-AE1F-E4194AE2E051}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2BAE2439-DB76-4DCA-AE1F-E4194AE2E051}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2BAE2439-DB76-4DCA-AE1F-E4194AE2E051}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2BAE2439-DB76-4DCA-AE1F-E4194AE2E051}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2B28DA2A-0DBB-4B05-BA2D-438529D7C311} + EndGlobalSection +EndGlobal diff --git a/backend/API/Controllers/WeatherForecastController.cs b/backend/API/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..aaf3a93 --- /dev/null +++ b/backend/API/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace API.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [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/backend/API/Program.cs b/backend/API/Program.cs new file mode 100644 index 0000000..48863a6 --- /dev/null +++ b/backend/API/Program.cs @@ -0,0 +1,25 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/backend/API/Properties/launchSettings.json b/backend/API/Properties/launchSettings.json new file mode 100644 index 0000000..47e9691 --- /dev/null +++ b/backend/API/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:19016", + "sslPort": 44314 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5218", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7017;http://localhost:5218", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/backend/API/WeatherForecast.cs b/backend/API/WeatherForecast.cs new file mode 100644 index 0000000..10c41a8 --- /dev/null +++ b/backend/API/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace API +{ + 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; } + } +}