diff --git a/TeamCalendar.API/Controllers/WeatherForecastController.cs b/TeamCalendar.API/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..d44b440 --- /dev/null +++ b/TeamCalendar.API/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace TeamCalendar.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/TeamCalendar.API/Program.cs b/TeamCalendar.API/Program.cs new file mode 100644 index 0000000..48863a6 --- /dev/null +++ b/TeamCalendar.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/TeamCalendar.API/Properties/launchSettings.json b/TeamCalendar.API/Properties/launchSettings.json new file mode 100644 index 0000000..d37808a --- /dev/null +++ b/TeamCalendar.API/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:52431", + "sslPort": 44374 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5227", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7062;http://localhost:5227", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/TeamCalendar.API/TeamCalendar.API.csproj b/TeamCalendar.API/TeamCalendar.API.csproj new file mode 100644 index 0000000..ba558e4 --- /dev/null +++ b/TeamCalendar.API/TeamCalendar.API.csproj @@ -0,0 +1,14 @@ + + + + net8.0 + enable + enable + true + + + + + + + diff --git a/TeamCalendar.API/TeamCalendar.API.http b/TeamCalendar.API/TeamCalendar.API.http new file mode 100644 index 0000000..4da8646 --- /dev/null +++ b/TeamCalendar.API/TeamCalendar.API.http @@ -0,0 +1,6 @@ +@TeamCalendar.API_HostAddress = http://localhost:5227 + +GET {{TeamCalendar.API_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/TeamCalendar.API/WeatherForecast.cs b/TeamCalendar.API/WeatherForecast.cs new file mode 100644 index 0000000..266e9b6 --- /dev/null +++ b/TeamCalendar.API/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace TeamCalendar.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; } + } +} diff --git a/TeamCalendar.API/appsettings.Development.json b/TeamCalendar.API/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/TeamCalendar.API/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/TeamCalendar.API/appsettings.json b/TeamCalendar.API/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/TeamCalendar.API/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/TeamCalendar.sln b/TeamCalendar.sln new file mode 100644 index 0000000..c57bfad --- /dev/null +++ b/TeamCalendar.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34330.188 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamCalendar.API", "TeamCalendar.API\TeamCalendar.API.csproj", "{105837B8-0E49-4F32-9F15-D23A0CE63A22}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {105837B8-0E49-4F32-9F15-D23A0CE63A22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {105837B8-0E49-4F32-9F15-D23A0CE63A22}.Debug|Any CPU.Build.0 = Debug|Any CPU + {105837B8-0E49-4F32-9F15-D23A0CE63A22}.Release|Any CPU.ActiveCfg = Release|Any CPU + {105837B8-0E49-4F32-9F15-D23A0CE63A22}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {16B1AC15-74F3-4D6B-AF90-6F9105B03A4C} + EndGlobalSection +EndGlobal