From 3c2a3831032a794c35f7a3adedfe86635807e49e Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Sun, 7 Apr 2024 01:22:23 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20RESTAPI=20=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SecuritySystem/SecuritySystem.sln | 14 +++++++ .../Controllers/WeatherForecastController.cs | 33 +++++++++++++++ .../SecuritySystemRestApi/Program.cs | 41 +++++++++++++++++++ .../Properties/launchSettings.json | 31 ++++++++++++++ .../SecuritySystemRestApi.csproj | 19 +++++++++ .../SecuritySystemRestApi/WeatherForecast.cs | 13 ++++++ .../appsettings.Development.json | 8 ++++ .../SecuritySystemRestApi/appsettings.json | 9 ++++ 8 files changed, 168 insertions(+) create mode 100644 SecuritySystem/SecuritySystemRestApi/Controllers/WeatherForecastController.cs create mode 100644 SecuritySystem/SecuritySystemRestApi/Program.cs create mode 100644 SecuritySystem/SecuritySystemRestApi/Properties/launchSettings.json create mode 100644 SecuritySystem/SecuritySystemRestApi/SecuritySystemRestApi.csproj create mode 100644 SecuritySystem/SecuritySystemRestApi/WeatherForecast.cs create mode 100644 SecuritySystem/SecuritySystemRestApi/appsettings.Development.json create mode 100644 SecuritySystem/SecuritySystemRestApi/appsettings.json diff --git a/SecuritySystem/SecuritySystem.sln b/SecuritySystem/SecuritySystem.sln index a29e895..d9263be 100644 --- a/SecuritySystem/SecuritySystem.sln +++ b/SecuritySystem/SecuritySystem.sln @@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemFileImplement EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemDatabaseImplement", "SecuritySystemDatabaseImplement\SecuritySystemDatabaseImplement.csproj", "{4AE7461C-39CC-463B-B5A1-A47ED3B9E925}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemRestApi", "SecuritySystemRestApi\SecuritySystemRestApi.csproj", "{A45C62CE-D0FF-4347-A6FF-773A6563BDA9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -111,6 +113,18 @@ Global {4AE7461C-39CC-463B-B5A1-A47ED3B9E925}.Release|x64.Build.0 = Release|x64 {4AE7461C-39CC-463B-B5A1-A47ED3B9E925}.Release|x86.ActiveCfg = Release|Any CPU {4AE7461C-39CC-463B-B5A1-A47ED3B9E925}.Release|x86.Build.0 = Release|Any CPU + {A45C62CE-D0FF-4347-A6FF-773A6563BDA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A45C62CE-D0FF-4347-A6FF-773A6563BDA9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A45C62CE-D0FF-4347-A6FF-773A6563BDA9}.Debug|x64.ActiveCfg = Debug|Any CPU + {A45C62CE-D0FF-4347-A6FF-773A6563BDA9}.Debug|x64.Build.0 = Debug|Any CPU + {A45C62CE-D0FF-4347-A6FF-773A6563BDA9}.Debug|x86.ActiveCfg = Debug|Any CPU + {A45C62CE-D0FF-4347-A6FF-773A6563BDA9}.Debug|x86.Build.0 = Debug|Any CPU + {A45C62CE-D0FF-4347-A6FF-773A6563BDA9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A45C62CE-D0FF-4347-A6FF-773A6563BDA9}.Release|Any CPU.Build.0 = Release|Any CPU + {A45C62CE-D0FF-4347-A6FF-773A6563BDA9}.Release|x64.ActiveCfg = Release|Any CPU + {A45C62CE-D0FF-4347-A6FF-773A6563BDA9}.Release|x64.Build.0 = Release|Any CPU + {A45C62CE-D0FF-4347-A6FF-773A6563BDA9}.Release|x86.ActiveCfg = Release|Any CPU + {A45C62CE-D0FF-4347-A6FF-773A6563BDA9}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SecuritySystem/SecuritySystemRestApi/Controllers/WeatherForecastController.cs b/SecuritySystem/SecuritySystemRestApi/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..7cb394e --- /dev/null +++ b/SecuritySystem/SecuritySystemRestApi/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace SecuritySystemRestApi.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/SecuritySystem/SecuritySystemRestApi/Program.cs b/SecuritySystem/SecuritySystemRestApi/Program.cs new file mode 100644 index 0000000..68f2f70 --- /dev/null +++ b/SecuritySystem/SecuritySystemRestApi/Program.cs @@ -0,0 +1,41 @@ +using SecuritySystemBusinessLogic.BusinessLogics; +using SecuritySystemContracts.BusinessLogicsContracts; +using SecuritySystemContracts.StoragesContracts; +using SecuritySystemDatabaseImplement.Implements; +using Microsoft.OpenApi.Models; + +var builder = WebApplication.CreateBuilder(args); +builder.Logging.SetMinimumLevel(LogLevel.Trace); +builder.Logging.AddLog4Net("log4net.config"); + +// Add services to the container. +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddControllers(); + +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(c => +{ + c.SwaggerDoc("v1", new OpenApiInfo + { + Title = "SecuritySystemRestApi", + Version = "v1" + }); +}); + +var app = builder.Build(); +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "SecuritySystemRestApi v1")); +} +app.UseHttpsRedirection(); +app.UseAuthorization(); +app.MapControllers(); +app.Run(); \ No newline at end of file diff --git a/SecuritySystem/SecuritySystemRestApi/Properties/launchSettings.json b/SecuritySystem/SecuritySystemRestApi/Properties/launchSettings.json new file mode 100644 index 0000000..63c2ddd --- /dev/null +++ b/SecuritySystem/SecuritySystemRestApi/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:38474", + "sslPort": 44377 + } + }, + "profiles": { + "SecuritySystemRestApi": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7129;http://localhost:5257", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/SecuritySystem/SecuritySystemRestApi/SecuritySystemRestApi.csproj b/SecuritySystem/SecuritySystemRestApi/SecuritySystemRestApi.csproj new file mode 100644 index 0000000..5eaee34 --- /dev/null +++ b/SecuritySystem/SecuritySystemRestApi/SecuritySystemRestApi.csproj @@ -0,0 +1,19 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + diff --git a/SecuritySystem/SecuritySystemRestApi/WeatherForecast.cs b/SecuritySystem/SecuritySystemRestApi/WeatherForecast.cs new file mode 100644 index 0000000..a736ab8 --- /dev/null +++ b/SecuritySystem/SecuritySystemRestApi/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace SecuritySystemRestApi +{ + 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/SecuritySystem/SecuritySystemRestApi/appsettings.Development.json b/SecuritySystem/SecuritySystemRestApi/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/SecuritySystem/SecuritySystemRestApi/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/SecuritySystem/SecuritySystemRestApi/appsettings.json b/SecuritySystem/SecuritySystemRestApi/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/SecuritySystem/SecuritySystemRestApi/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}