diff --git a/AB-API.sln b/AB-API.sln new file mode 100644 index 0000000..66ac6c2 --- /dev/null +++ b/AB-API.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33205.214 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AB-API", "AB-API\AB-API.csproj", "{45855EEB-EA31-476F-A020-1A3B71AD725A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {45855EEB-EA31-476F-A020-1A3B71AD725A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {45855EEB-EA31-476F-A020-1A3B71AD725A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {45855EEB-EA31-476F-A020-1A3B71AD725A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {45855EEB-EA31-476F-A020-1A3B71AD725A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C7D1722E-5C50-4F16-BA7D-79977DD1D621} + EndGlobalSection +EndGlobal diff --git a/AB-API/AB-API.csproj b/AB-API/AB-API.csproj new file mode 100644 index 0000000..d72748d --- /dev/null +++ b/AB-API/AB-API.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + AB_API + + + + + + + diff --git a/AB-API/Controllers/WeatherForecastController.cs b/AB-API/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..4119bef --- /dev/null +++ b/AB-API/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace AB_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 = DateTime.Now.AddDays(index), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} \ No newline at end of file diff --git a/AB-API/Program.cs b/AB-API/Program.cs new file mode 100644 index 0000000..48863a6 --- /dev/null +++ b/AB-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/AB-API/Properties/launchSettings.json b/AB-API/Properties/launchSettings.json new file mode 100644 index 0000000..0eee122 --- /dev/null +++ b/AB-API/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:25034", + "sslPort": 44354 + } + }, + "profiles": { + "AB_API": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7196;http://localhost:5286", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/AB-API/WeatherForecast.cs b/AB-API/WeatherForecast.cs new file mode 100644 index 0000000..117f86d --- /dev/null +++ b/AB-API/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace AB_API +{ + public class WeatherForecast + { + public DateTime 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/AB-API/appsettings.Development.json b/AB-API/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/AB-API/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/AB-API/appsettings.json b/AB-API/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/AB-API/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}