diff options
Diffstat (limited to 'PersonalApi')
-rw-r--r-- | PersonalApi/Controllers/ActivityController.cs | 11 | ||||
-rw-r--r-- | PersonalApi/Controllers/WeatherForecastController.cs | 34 | ||||
-rw-r--r-- | PersonalApi/Models/Actvity.cs | 6 | ||||
-rw-r--r-- | PersonalApi/Models/WeatherForecast.cs | 13 | ||||
-rw-r--r-- | PersonalApi/PersonalApi.csproj | 13 | ||||
-rw-r--r-- | PersonalApi/PersonalApi.http | 6 | ||||
-rw-r--r-- | PersonalApi/Program.cs | 25 | ||||
-rw-r--r-- | PersonalApi/Properties/launchSettings.json | 41 | ||||
-rw-r--r-- | PersonalApi/appsettings.Development.json | 8 | ||||
-rw-r--r-- | PersonalApi/appsettings.json | 9 |
10 files changed, 166 insertions, 0 deletions
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 @@ | |||
1 | using Microsoft.AspNetCore.Http; | ||
2 | using Microsoft.AspNetCore.Mvc; | ||
3 | |||
4 | namespace PersonalApi.Controllers | ||
5 | { | ||
6 | [Route("[controller]")] | ||
7 | [ApiController] | ||
8 | public class ActivityController : ControllerBase | ||
9 | { | ||
10 | } | ||
11 | } | ||
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 @@ | |||
1 | using Microsoft.AspNetCore.Mvc; | ||
2 | using PersonalApi.Models; | ||
3 | |||
4 | namespace PersonalApi.Controllers | ||
5 | { | ||
6 | [ApiController] | ||
7 | [Route("[controller]")] | ||
8 | public class WeatherForecastController : ControllerBase | ||
9 | { | ||
10 | private static readonly string[] Summaries = new[] | ||
11 | { | ||
12 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" | ||
13 | }; | ||
14 | |||
15 | private readonly ILogger<WeatherForecastController> _logger; | ||
16 | |||
17 | public WeatherForecastController(ILogger<WeatherForecastController> logger) | ||
18 | { | ||
19 | _logger = logger; | ||
20 | } | ||
21 | |||
22 | [HttpGet(Name = "GetWeatherForecast")] | ||
23 | public IEnumerable<WeatherForecast> Get() | ||
24 | { | ||
25 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast | ||
26 | { | ||
27 | Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), | ||
28 | TemperatureC = Random.Shared.Next(-20, 55), | ||
29 | Summary = Summaries[Random.Shared.Next(Summaries.Length)] | ||
30 | }) | ||
31 | .ToArray(); | ||
32 | } | ||
33 | } | ||
34 | } | ||
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 @@ | |||
1 | namespace PersonalApi.Models | ||
2 | { | ||
3 | public class Actvity | ||
4 | { | ||
5 | } | ||
6 | } | ||
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 @@ | |||
1 | namespace PersonalApi.Models | ||
2 | { | ||
3 | public class WeatherForecast | ||
4 | { | ||
5 | public DateOnly Date { get; set; } | ||
6 | |||
7 | public int TemperatureC { get; set; } | ||
8 | |||
9 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); | ||
10 | |||
11 | public string? Summary { get; set; } | ||
12 | } | ||
13 | } | ||
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 @@ | |||
1 | <Project Sdk="Microsoft.NET.Sdk.Web"> | ||
2 | |||
3 | <PropertyGroup> | ||
4 | <TargetFramework>net8.0</TargetFramework> | ||
5 | <Nullable>enable</Nullable> | ||
6 | <ImplicitUsings>enable</ImplicitUsings> | ||
7 | </PropertyGroup> | ||
8 | |||
9 | <ItemGroup> | ||
10 | <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" /> | ||
11 | </ItemGroup> | ||
12 | |||
13 | </Project> | ||
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 @@ | |||
1 | @PersonalApi_HostAddress = http://localhost:5006 | ||
2 | |||
3 | GET {{PersonalApi_HostAddress}}/weatherforecast/ | ||
4 | Accept: application/json | ||
5 | |||
6 | ### | ||
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 @@ | |||
1 | var builder = WebApplication.CreateBuilder(args); | ||
2 | |||
3 | // Add services to the container. | ||
4 | |||
5 | builder.Services.AddControllers(); | ||
6 | // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle | ||
7 | builder.Services.AddEndpointsApiExplorer(); | ||
8 | builder.Services.AddSwaggerGen(); | ||
9 | |||
10 | var app = builder.Build(); | ||
11 | |||
12 | // Configure the HTTP request pipeline. | ||
13 | if (app.Environment.IsDevelopment()) | ||
14 | { | ||
15 | app.UseSwagger(); | ||
16 | app.UseSwaggerUI(); | ||
17 | } | ||
18 | |||
19 | app.UseHttpsRedirection(); | ||
20 | |||
21 | app.UseAuthorization(); | ||
22 | |||
23 | app.MapControllers(); | ||
24 | |||
25 | 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 @@ | |||
1 | { | ||
2 | "$schema": "http://json.schemastore.org/launchsettings.json", | ||
3 | "iisSettings": { | ||
4 | "windowsAuthentication": false, | ||
5 | "anonymousAuthentication": true, | ||
6 | "iisExpress": { | ||
7 | "applicationUrl": "http://localhost:26722", | ||
8 | "sslPort": 44383 | ||
9 | } | ||
10 | }, | ||
11 | "profiles": { | ||
12 | "http": { | ||
13 | "commandName": "Project", | ||
14 | "dotnetRunMessages": true, | ||
15 | "launchBrowser": true, | ||
16 | "launchUrl": "swagger", | ||
17 | "applicationUrl": "http://localhost:5006", | ||
18 | "environmentVariables": { | ||
19 | "ASPNETCORE_ENVIRONMENT": "Development" | ||
20 | } | ||
21 | }, | ||
22 | "https": { | ||
23 | "commandName": "Project", | ||
24 | "dotnetRunMessages": true, | ||
25 | "launchBrowser": true, | ||
26 | "launchUrl": "swagger", | ||
27 | "applicationUrl": "https://localhost:7135;http://localhost:5006", | ||
28 | "environmentVariables": { | ||
29 | "ASPNETCORE_ENVIRONMENT": "Development" | ||
30 | } | ||
31 | }, | ||
32 | "IIS Express": { | ||
33 | "commandName": "IISExpress", | ||
34 | "launchBrowser": true, | ||
35 | "launchUrl": "swagger", | ||
36 | "environmentVariables": { | ||
37 | "ASPNETCORE_ENVIRONMENT": "Development" | ||
38 | } | ||
39 | } | ||
40 | } | ||
41 | } | ||
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 @@ | |||
1 | { | ||
2 | "Logging": { | ||
3 | "LogLevel": { | ||
4 | "Default": "Information", | ||
5 | "Microsoft.AspNetCore": "Warning" | ||
6 | } | ||
7 | } | ||
8 | } | ||
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 @@ | |||
1 | { | ||
2 | "Logging": { | ||
3 | "LogLevel": { | ||
4 | "Default": "Information", | ||
5 | "Microsoft.AspNetCore": "Warning" | ||
6 | } | ||
7 | }, | ||
8 | "AllowedHosts": "*" | ||
9 | } | ||