diff --git a/SurveyBackend/SurveyBackend.sln b/SurveyBackend/SurveyBackend.sln new file mode 100644 index 0000000..b7d1a9a --- /dev/null +++ b/SurveyBackend/SurveyBackend.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SurveyBackend", "SurveyBackend\SurveyBackend.csproj", "{2941E98A-5311-4B97-B8B0-8DBF5E1C3B56}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2941E98A-5311-4B97-B8B0-8DBF5E1C3B56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2941E98A-5311-4B97-B8B0-8DBF5E1C3B56}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2941E98A-5311-4B97-B8B0-8DBF5E1C3B56}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2941E98A-5311-4B97-B8B0-8DBF5E1C3B56}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/SurveyBackend/SurveyBackend/Program.cs b/SurveyBackend/SurveyBackend/Program.cs new file mode 100644 index 0000000..5a9ed2b --- /dev/null +++ b/SurveyBackend/SurveyBackend/Program.cs @@ -0,0 +1,51 @@ +namespace SurveyBackend; + +public class Program +{ + public static void Main(string[] args) + { + var builder = WebApplication.CreateBuilder(args); + + // Add services to the container. + builder.Services.AddAuthorization(); + + // 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(); + + var summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + app.MapGet("/weatherforecast", (HttpContext httpContext) => + { + var forecast = 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(); + return forecast; + }) + .WithName("GetWeatherForecast") + .WithOpenApi(); + + app.Run(); + } +} \ No newline at end of file diff --git a/SurveyBackend/SurveyBackend/Properties/launchSettings.json b/SurveyBackend/SurveyBackend/Properties/launchSettings.json new file mode 100644 index 0000000..589b161 --- /dev/null +++ b/SurveyBackend/SurveyBackend/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:21107", + "sslPort": 44349 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5231", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7267;http://localhost:5231", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/SurveyBackend/SurveyBackend/SurveyBackend.csproj b/SurveyBackend/SurveyBackend/SurveyBackend.csproj new file mode 100644 index 0000000..1060e38 --- /dev/null +++ b/SurveyBackend/SurveyBackend/SurveyBackend.csproj @@ -0,0 +1,14 @@ + + + + net8.0 + enable + enable + + + + + + + + diff --git a/SurveyBackend/SurveyBackend/SurveyBackend.http b/SurveyBackend/SurveyBackend/SurveyBackend.http new file mode 100644 index 0000000..0572374 --- /dev/null +++ b/SurveyBackend/SurveyBackend/SurveyBackend.http @@ -0,0 +1,6 @@ +@SurveyBackend_HostAddress = http://localhost:5231 + +GET {{SurveyBackend_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/SurveyBackend/SurveyBackend/WeatherForecast.cs b/SurveyBackend/SurveyBackend/WeatherForecast.cs new file mode 100644 index 0000000..75b15b6 --- /dev/null +++ b/SurveyBackend/SurveyBackend/WeatherForecast.cs @@ -0,0 +1,12 @@ +namespace SurveyBackend; + +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; } +} \ No newline at end of file diff --git a/SurveyBackend/SurveyBackend/appsettings.Development.json b/SurveyBackend/SurveyBackend/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/SurveyBackend/SurveyBackend/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/SurveyBackend/SurveyBackend/appsettings.json b/SurveyBackend/SurveyBackend/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/SurveyBackend/SurveyBackend/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}