From d661d795913c1805df19bd2073145f7cfea3c182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D1=82=D1=8F=20=D0=98=D1=85=D0=BE=D0=BD=D0=BA?= =?UTF-8?q?=D0=B8=D0=BD=D0=B0?= Date: Wed, 5 Apr 2023 20:18:52 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PrecastConcretePlant/PrecastConcretePlant.sln | 6 ++++ .../Controllers/WeatherForecastController.cs | 33 +++++++++++++++++++ .../PrecastConcretePlantRestApi.csproj | 18 ++++++++++ PrecastConcretePlantRestApi/Program.cs | 25 ++++++++++++++ .../Properties/launchSettings.json | 31 +++++++++++++++++ .../WeatherForecast.cs | 13 ++++++++ .../appsettings.Development.json | 8 +++++ PrecastConcretePlantRestApi/appsettings.json | 9 +++++ 8 files changed, 143 insertions(+) create mode 100644 PrecastConcretePlantRestApi/Controllers/WeatherForecastController.cs create mode 100644 PrecastConcretePlantRestApi/PrecastConcretePlantRestApi.csproj create mode 100644 PrecastConcretePlantRestApi/Program.cs create mode 100644 PrecastConcretePlantRestApi/Properties/launchSettings.json create mode 100644 PrecastConcretePlantRestApi/WeatherForecast.cs create mode 100644 PrecastConcretePlantRestApi/appsettings.Development.json create mode 100644 PrecastConcretePlantRestApi/appsettings.json diff --git a/PrecastConcretePlant/PrecastConcretePlant.sln b/PrecastConcretePlant/PrecastConcretePlant.sln index ec3631c..9c7e08b 100644 --- a/PrecastConcretePlant/PrecastConcretePlant.sln +++ b/PrecastConcretePlant/PrecastConcretePlant.sln @@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantFileImp EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantDatabaseImplement", "..\PrecastConcretePlantDataBaseImplemet\PrecastConcretePlantDatabaseImplement.csproj", "{8E649C11-1085-49FC-BC7A-CACB558CB39A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantRestApi", "..\PrecastConcretePlantRestApi\PrecastConcretePlantRestApi.csproj", "{5677937A-39C7-4D1A-B837-0736EEC0A738}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -51,6 +53,10 @@ Global {8E649C11-1085-49FC-BC7A-CACB558CB39A}.Debug|Any CPU.Build.0 = Debug|Any CPU {8E649C11-1085-49FC-BC7A-CACB558CB39A}.Release|Any CPU.ActiveCfg = Release|Any CPU {8E649C11-1085-49FC-BC7A-CACB558CB39A}.Release|Any CPU.Build.0 = Release|Any CPU + {5677937A-39C7-4D1A-B837-0736EEC0A738}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5677937A-39C7-4D1A-B837-0736EEC0A738}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5677937A-39C7-4D1A-B837-0736EEC0A738}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5677937A-39C7-4D1A-B837-0736EEC0A738}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/PrecastConcretePlantRestApi/Controllers/WeatherForecastController.cs b/PrecastConcretePlantRestApi/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..e539bf2 --- /dev/null +++ b/PrecastConcretePlantRestApi/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace PrecastConcretePlantRestApi.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/PrecastConcretePlantRestApi/PrecastConcretePlantRestApi.csproj b/PrecastConcretePlantRestApi/PrecastConcretePlantRestApi.csproj new file mode 100644 index 0000000..bc33f3e --- /dev/null +++ b/PrecastConcretePlantRestApi/PrecastConcretePlantRestApi.csproj @@ -0,0 +1,18 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + diff --git a/PrecastConcretePlantRestApi/Program.cs b/PrecastConcretePlantRestApi/Program.cs new file mode 100644 index 0000000..48863a6 --- /dev/null +++ b/PrecastConcretePlantRestApi/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/PrecastConcretePlantRestApi/Properties/launchSettings.json b/PrecastConcretePlantRestApi/Properties/launchSettings.json new file mode 100644 index 0000000..f144ced --- /dev/null +++ b/PrecastConcretePlantRestApi/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:39315", + "sslPort": 44358 + } + }, + "profiles": { + "PrecastConcretePlantRestApi": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7178;http://localhost:5178", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/PrecastConcretePlantRestApi/WeatherForecast.cs b/PrecastConcretePlantRestApi/WeatherForecast.cs new file mode 100644 index 0000000..f76022c --- /dev/null +++ b/PrecastConcretePlantRestApi/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace PrecastConcretePlantRestApi +{ + 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/PrecastConcretePlantRestApi/appsettings.Development.json b/PrecastConcretePlantRestApi/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/PrecastConcretePlantRestApi/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/PrecastConcretePlantRestApi/appsettings.json b/PrecastConcretePlantRestApi/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/PrecastConcretePlantRestApi/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}