diff --git a/VideoGameCharacterApi.slnx b/VideoGameCharacterApi.slnx new file mode 100644 index 0000000..2ab2cf5 --- /dev/null +++ b/VideoGameCharacterApi.slnx @@ -0,0 +1,3 @@ + + + diff --git a/VideoGameCharacterApi/Controllers/WeatherForecastController.cs b/VideoGameCharacterApi/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..e51bb31 --- /dev/null +++ b/VideoGameCharacterApi/Controllers/WeatherForecastController.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Mvc; + +namespace VideoGameCharacterApi.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/VideoGameCharacterApi/Program.cs b/VideoGameCharacterApi/Program.cs new file mode 100644 index 0000000..666a9c5 --- /dev/null +++ b/VideoGameCharacterApi/Program.cs @@ -0,0 +1,23 @@ +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/VideoGameCharacterApi/Properties/launchSettings.json b/VideoGameCharacterApi/Properties/launchSettings.json new file mode 100644 index 0000000..ca314d3 --- /dev/null +++ b/VideoGameCharacterApi/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:5088", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7093;http://localhost:5088", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/VideoGameCharacterApi/VideoGameCharacterApi.csproj b/VideoGameCharacterApi/VideoGameCharacterApi.csproj new file mode 100644 index 0000000..530dd4e --- /dev/null +++ b/VideoGameCharacterApi/VideoGameCharacterApi.csproj @@ -0,0 +1,13 @@ + + + + net10.0 + enable + enable + + + + + + + diff --git a/VideoGameCharacterApi/VideoGameCharacterApi.http b/VideoGameCharacterApi/VideoGameCharacterApi.http new file mode 100644 index 0000000..4090199 --- /dev/null +++ b/VideoGameCharacterApi/VideoGameCharacterApi.http @@ -0,0 +1,6 @@ +@VideoGameCharacterApi_HostAddress = http://localhost:5088 + +GET {{VideoGameCharacterApi_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/VideoGameCharacterApi/WeatherForecast.cs b/VideoGameCharacterApi/WeatherForecast.cs new file mode 100644 index 0000000..2282e88 --- /dev/null +++ b/VideoGameCharacterApi/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace VideoGameCharacterApi +{ + 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/VideoGameCharacterApi/appsettings.Development.json b/VideoGameCharacterApi/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/VideoGameCharacterApi/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/VideoGameCharacterApi/appsettings.json b/VideoGameCharacterApi/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/VideoGameCharacterApi/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}