From 59ddcc2041d39469da19c34f6e33623ef72be963 Mon Sep 17 00:00:00 2001 From: ujijrujijr Date: Sat, 27 Apr 2024 16:07:34 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82=20=D0=BF=D1=80=D0=B8=D0=BB?= =?UTF-8?q?=D0=BE=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D0=BD=D0=B8=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ComputerShop.sln | 12 +++++-- .../ComputerShopImplementerApp.csproj | 13 ++++++++ .../Controllers/WeatherForecastController.cs | 33 +++++++++++++++++++ ComputerShopImplementerApp/Program.cs | 25 ++++++++++++++ .../Properties/launchSettings.json | 31 +++++++++++++++++ ComputerShopImplementerApp/WeatherForecast.cs | 13 ++++++++ .../appsettings.Development.json | 8 +++++ ComputerShopImplementerApp/appsettings.json | 9 +++++ 8 files changed, 141 insertions(+), 3 deletions(-) create mode 100644 ComputerShopImplementerApp/ComputerShopImplementerApp.csproj create mode 100644 ComputerShopImplementerApp/Controllers/WeatherForecastController.cs create mode 100644 ComputerShopImplementerApp/Program.cs create mode 100644 ComputerShopImplementerApp/Properties/launchSettings.json create mode 100644 ComputerShopImplementerApp/WeatherForecast.cs create mode 100644 ComputerShopImplementerApp/appsettings.Development.json create mode 100644 ComputerShopImplementerApp/appsettings.json diff --git a/ComputerShop.sln b/ComputerShop.sln index 692a628..2290c48 100644 --- a/ComputerShop.sln +++ b/ComputerShop.sln @@ -7,11 +7,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerShopRestApi", "Comp EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerShopDataModels", "ComputerShopDataModels\ComputerShopDataModels.csproj", "{BBCF398B-D800-4D8D-99E8-F7ED2CC14A65}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerShopContracts", "ComputerShopContracts\ComputerShopContracts.csproj", "{B197888D-702B-4122-BFBF-BA6BCB49C0F3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerShopContracts", "ComputerShopContracts\ComputerShopContracts.csproj", "{B197888D-702B-4122-BFBF-BA6BCB49C0F3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerShopBusinessLogic", "ComputerShopBusinessLogic\ComputerShopBusinessLogic.csproj", "{82FCBA71-AC54-45C8-9B21-BCB3DF6E085B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerShopBusinessLogic", "ComputerShopBusinessLogic\ComputerShopBusinessLogic.csproj", "{82FCBA71-AC54-45C8-9B21-BCB3DF6E085B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerShopDatabaseImplement", "ComputerShopDatabaseImplement\ComputerShopDatabaseImplement.csproj", "{CDE4C963-67B5-47A6-A394-901E95EA40F7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerShopDatabaseImplement", "ComputerShopDatabaseImplement\ComputerShopDatabaseImplement.csproj", "{CDE4C963-67B5-47A6-A394-901E95EA40F7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerShopImplementerApp", "ComputerShopImplementerApp\ComputerShopImplementerApp.csproj", "{FD166DD5-DB40-47B1-8D1A-9375D5A47FDC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -39,6 +41,10 @@ Global {CDE4C963-67B5-47A6-A394-901E95EA40F7}.Debug|Any CPU.Build.0 = Debug|Any CPU {CDE4C963-67B5-47A6-A394-901E95EA40F7}.Release|Any CPU.ActiveCfg = Release|Any CPU {CDE4C963-67B5-47A6-A394-901E95EA40F7}.Release|Any CPU.Build.0 = Release|Any CPU + {FD166DD5-DB40-47B1-8D1A-9375D5A47FDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FD166DD5-DB40-47B1-8D1A-9375D5A47FDC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FD166DD5-DB40-47B1-8D1A-9375D5A47FDC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FD166DD5-DB40-47B1-8D1A-9375D5A47FDC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ComputerShopImplementerApp/ComputerShopImplementerApp.csproj b/ComputerShopImplementerApp/ComputerShopImplementerApp.csproj new file mode 100644 index 0000000..2c33b1c --- /dev/null +++ b/ComputerShopImplementerApp/ComputerShopImplementerApp.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/ComputerShopImplementerApp/Controllers/WeatherForecastController.cs b/ComputerShopImplementerApp/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..3f43fdd --- /dev/null +++ b/ComputerShopImplementerApp/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace ComputerShopImplementerApp.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/ComputerShopImplementerApp/Program.cs b/ComputerShopImplementerApp/Program.cs new file mode 100644 index 0000000..d7a851e --- /dev/null +++ b/ComputerShopImplementerApp/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/ComputerShopImplementerApp/Properties/launchSettings.json b/ComputerShopImplementerApp/Properties/launchSettings.json new file mode 100644 index 0000000..8cfa586 --- /dev/null +++ b/ComputerShopImplementerApp/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:9116", + "sslPort": 44362 + } + }, + "profiles": { + "ComputerShopImplementerApp": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7169;http://localhost:5058", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/ComputerShopImplementerApp/WeatherForecast.cs b/ComputerShopImplementerApp/WeatherForecast.cs new file mode 100644 index 0000000..911dab2 --- /dev/null +++ b/ComputerShopImplementerApp/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace ComputerShopImplementerApp +{ + 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/ComputerShopImplementerApp/appsettings.Development.json b/ComputerShopImplementerApp/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/ComputerShopImplementerApp/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/ComputerShopImplementerApp/appsettings.json b/ComputerShopImplementerApp/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/ComputerShopImplementerApp/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}