From 135a9e75e180f3276cceb4e37415f84906e66016 Mon Sep 17 00:00:00 2001 From: Zach Berwaldt Date: Tue, 20 Aug 2024 19:27:34 -0400 Subject: Add project files. --- PersonalApi.sln | 25 +++++++++++++ PersonalApi/Controllers/ActivityController.cs | 11 ++++++ .../Controllers/WeatherForecastController.cs | 34 ++++++++++++++++++ PersonalApi/Models/Actvity.cs | 6 ++++ PersonalApi/Models/WeatherForecast.cs | 13 +++++++ PersonalApi/PersonalApi.csproj | 13 +++++++ PersonalApi/PersonalApi.http | 6 ++++ PersonalApi/Program.cs | 25 +++++++++++++ PersonalApi/Properties/launchSettings.json | 41 ++++++++++++++++++++++ PersonalApi/appsettings.Development.json | 8 +++++ PersonalApi/appsettings.json | 9 +++++ 11 files changed, 191 insertions(+) create mode 100644 PersonalApi.sln create mode 100644 PersonalApi/Controllers/ActivityController.cs create mode 100644 PersonalApi/Controllers/WeatherForecastController.cs create mode 100644 PersonalApi/Models/Actvity.cs create mode 100644 PersonalApi/Models/WeatherForecast.cs create mode 100644 PersonalApi/PersonalApi.csproj create mode 100644 PersonalApi/PersonalApi.http create mode 100644 PersonalApi/Program.cs create mode 100644 PersonalApi/Properties/launchSettings.json create mode 100644 PersonalApi/appsettings.Development.json create mode 100644 PersonalApi/appsettings.json diff --git a/PersonalApi.sln b/PersonalApi.sln new file mode 100644 index 0000000..1858a6b --- /dev/null +++ b/PersonalApi.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35208.52 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PersonalApi", "PersonalApi\PersonalApi.csproj", "{904FDE23-105B-4800-A626-2B9266CF40B8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {904FDE23-105B-4800-A626-2B9266CF40B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {904FDE23-105B-4800-A626-2B9266CF40B8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {904FDE23-105B-4800-A626-2B9266CF40B8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {904FDE23-105B-4800-A626-2B9266CF40B8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {60A9B1B9-8F72-49EE-B457-1D1D3E490476} + EndGlobalSection +EndGlobal diff --git a/PersonalApi/Controllers/ActivityController.cs b/PersonalApi/Controllers/ActivityController.cs new file mode 100644 index 0000000..73371da --- /dev/null +++ b/PersonalApi/Controllers/ActivityController.cs @@ -0,0 +1,11 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace PersonalApi.Controllers +{ + [Route("[controller]")] + [ApiController] + public class ActivityController : ControllerBase + { + } +} diff --git a/PersonalApi/Controllers/WeatherForecastController.cs b/PersonalApi/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..161a12a --- /dev/null +++ b/PersonalApi/Controllers/WeatherForecastController.cs @@ -0,0 +1,34 @@ +using Microsoft.AspNetCore.Mvc; +using PersonalApi.Models; + +namespace PersonalApi.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/PersonalApi/Models/Actvity.cs b/PersonalApi/Models/Actvity.cs new file mode 100644 index 0000000..2a58697 --- /dev/null +++ b/PersonalApi/Models/Actvity.cs @@ -0,0 +1,6 @@ +namespace PersonalApi.Models +{ + public class Actvity + { + } +} diff --git a/PersonalApi/Models/WeatherForecast.cs b/PersonalApi/Models/WeatherForecast.cs new file mode 100644 index 0000000..77a9b71 --- /dev/null +++ b/PersonalApi/Models/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace PersonalApi.Models +{ + 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/PersonalApi/PersonalApi.csproj b/PersonalApi/PersonalApi.csproj new file mode 100644 index 0000000..dbedb64 --- /dev/null +++ b/PersonalApi/PersonalApi.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/PersonalApi/PersonalApi.http b/PersonalApi/PersonalApi.http new file mode 100644 index 0000000..84c39aa --- /dev/null +++ b/PersonalApi/PersonalApi.http @@ -0,0 +1,6 @@ +@PersonalApi_HostAddress = http://localhost:5006 + +GET {{PersonalApi_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/PersonalApi/Program.cs b/PersonalApi/Program.cs new file mode 100644 index 0000000..48863a6 --- /dev/null +++ b/PersonalApi/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/PersonalApi/Properties/launchSettings.json b/PersonalApi/Properties/launchSettings.json new file mode 100644 index 0000000..6007ce3 --- /dev/null +++ b/PersonalApi/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:26722", + "sslPort": 44383 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5006", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7135;http://localhost:5006", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/PersonalApi/appsettings.Development.json b/PersonalApi/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/PersonalApi/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/PersonalApi/appsettings.json b/PersonalApi/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/PersonalApi/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} -- cgit v1.1