From 4eedfb402a75d7927fca67c479686ec1ed6433c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F=20=D0=A4=D0=B5=D0=B4=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 29 Apr 2024 21:57:01 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=BE=D0=BD=D1=82=D1=80=D0=BE=D0=BB?= =?UTF-8?q?=D0=BB=D0=B5=D1=80=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/MainController.cs | 9 +++++ .../Controllers/UserController.cs | 9 +++++ .../Controllers/WeatherForecastController.cs | 33 ------------------- .../ElectronicsShopResrAPI/Program.cs | 6 ++-- .../ElectronicsShopResrAPI/WeatherForecast.cs | 13 -------- 5 files changed, 22 insertions(+), 48 deletions(-) create mode 100644 ElectronicsShop/ElectronicsShopResrAPI/Controllers/MainController.cs create mode 100644 ElectronicsShop/ElectronicsShopResrAPI/Controllers/UserController.cs delete mode 100644 ElectronicsShop/ElectronicsShopResrAPI/Controllers/WeatherForecastController.cs delete mode 100644 ElectronicsShop/ElectronicsShopResrAPI/WeatherForecast.cs diff --git a/ElectronicsShop/ElectronicsShopResrAPI/Controllers/MainController.cs b/ElectronicsShop/ElectronicsShopResrAPI/Controllers/MainController.cs new file mode 100644 index 0000000..e11274f --- /dev/null +++ b/ElectronicsShop/ElectronicsShopResrAPI/Controllers/MainController.cs @@ -0,0 +1,9 @@ +using Microsoft.AspNetCore.Mvc; + +namespace ElectronicsShopResrAPI.Controllers { + public class MainController : Controller { + public IActionResult Index() { + return View(); + } + } +} diff --git a/ElectronicsShop/ElectronicsShopResrAPI/Controllers/UserController.cs b/ElectronicsShop/ElectronicsShopResrAPI/Controllers/UserController.cs new file mode 100644 index 0000000..4f95330 --- /dev/null +++ b/ElectronicsShop/ElectronicsShopResrAPI/Controllers/UserController.cs @@ -0,0 +1,9 @@ +using Microsoft.AspNetCore.Mvc; + +namespace ElectronicsShopResrAPI.Controllers { + public class UserController : Controller { + public IActionResult Index() { + return View(); + } + } +} diff --git a/ElectronicsShop/ElectronicsShopResrAPI/Controllers/WeatherForecastController.cs b/ElectronicsShop/ElectronicsShopResrAPI/Controllers/WeatherForecastController.cs deleted file mode 100644 index 9a094e4..0000000 --- a/ElectronicsShop/ElectronicsShopResrAPI/Controllers/WeatherForecastController.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Mvc; - -namespace ElectronicsShopResrAPI.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 = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), - TemperatureC = Random.Shared.Next(-20, 55), - Summary = Summaries[Random.Shared.Next(Summaries.Length)] - }) - .ToArray(); - } - } -} diff --git a/ElectronicsShop/ElectronicsShopResrAPI/Program.cs b/ElectronicsShop/ElectronicsShopResrAPI/Program.cs index 48863a6..d1b01f3 100644 --- a/ElectronicsShop/ElectronicsShopResrAPI/Program.cs +++ b/ElectronicsShop/ElectronicsShopResrAPI/Program.cs @@ -1,3 +1,5 @@ +using Microsoft.OpenApi.Models; + var builder = WebApplication.CreateBuilder(args); // Add services to the container. @@ -5,7 +7,7 @@ var builder = WebApplication.CreateBuilder(args); builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); -builder.Services.AddSwaggerGen(); +builder.Services.AddSwaggerGen(x => x.SwaggerDoc("v1", new OpenApiInfo { Title = "ElectronicsShopResrAPI", Version = "v1" })); var app = builder.Build(); @@ -13,7 +15,7 @@ var app = builder.Build(); if (app.Environment.IsDevelopment()) { app.UseSwagger(); - app.UseSwaggerUI(); + app.UseSwaggerUI(x => x.SwaggerEndpoint("/swagger/v1/swagger.json", "ElectronicsShopResrAPI v1")); } app.UseHttpsRedirection(); diff --git a/ElectronicsShop/ElectronicsShopResrAPI/WeatherForecast.cs b/ElectronicsShop/ElectronicsShopResrAPI/WeatherForecast.cs deleted file mode 100644 index f7a49c6..0000000 --- a/ElectronicsShop/ElectronicsShopResrAPI/WeatherForecast.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace ElectronicsShopResrAPI -{ - public class WeatherForecast - { - public DateOnly Date { get; set; } - - public int TemperatureC { get; set; } - - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - - public string? Summary { get; set; } - } -}