From 400f717f974dbf562ba1d70e80be69c36c7634b5 Mon Sep 17 00:00:00 2001 From: Gleb Lagov Date: Fri, 18 Nov 2022 18:41:22 +0300 Subject: [PATCH] project structure created --- Backend.Api/Backend.Api.csproj | 13 ++++++++ .../Controllers/WeatherForecastController.cs | 32 +++++++++++++++++++ Backend.Api/Program.cs | 25 +++++++++++++++ Backend.Api/Properties/launchSettings.json | 31 ++++++++++++++++++ Backend.Api/WeatherForecast.cs | 12 +++++++ Backend.Api/appsettings.Development.json | 8 +++++ Backend.Api/appsettings.json | 9 ++++++ Backend.sln | 22 +++++++++++++ 8 files changed, 152 insertions(+) create mode 100644 Backend.Api/Backend.Api.csproj create mode 100644 Backend.Api/Controllers/WeatherForecastController.cs create mode 100644 Backend.Api/Program.cs create mode 100644 Backend.Api/Properties/launchSettings.json create mode 100644 Backend.Api/WeatherForecast.cs create mode 100644 Backend.Api/appsettings.Development.json create mode 100644 Backend.Api/appsettings.json create mode 100644 Backend.sln diff --git a/Backend.Api/Backend.Api.csproj b/Backend.Api/Backend.Api.csproj new file mode 100644 index 0000000..60bf9ea --- /dev/null +++ b/Backend.Api/Backend.Api.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/Backend.Api/Controllers/WeatherForecastController.cs b/Backend.Api/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..42b7a67 --- /dev/null +++ b/Backend.Api/Controllers/WeatherForecastController.cs @@ -0,0 +1,32 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Backend.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(); + } +} diff --git a/Backend.Api/Program.cs b/Backend.Api/Program.cs new file mode 100644 index 0000000..48863a6 --- /dev/null +++ b/Backend.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/Backend.Api/Properties/launchSettings.json b/Backend.Api/Properties/launchSettings.json new file mode 100644 index 0000000..3a67877 --- /dev/null +++ b/Backend.Api/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:52732", + "sslPort": 44361 + } + }, + "profiles": { + "Backend.Api": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7070;http://localhost:5297", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Backend.Api/WeatherForecast.cs b/Backend.Api/WeatherForecast.cs new file mode 100644 index 0000000..2b0792b --- /dev/null +++ b/Backend.Api/WeatherForecast.cs @@ -0,0 +1,12 @@ +namespace Backend.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; } +} diff --git a/Backend.Api/appsettings.Development.json b/Backend.Api/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/Backend.Api/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Backend.Api/appsettings.json b/Backend.Api/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/Backend.Api/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Backend.sln b/Backend.sln new file mode 100644 index 0000000..522ef95 --- /dev/null +++ b/Backend.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Backend.Api", "Backend.Api\Backend.Api.csproj", "{38294DBD-1DCF-475E-BF0D-FC47A2ED808D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {38294DBD-1DCF-475E-BF0D-FC47A2ED808D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {38294DBD-1DCF-475E-BF0D-FC47A2ED808D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {38294DBD-1DCF-475E-BF0D-FC47A2ED808D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {38294DBD-1DCF-475E-BF0D-FC47A2ED808D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal