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; } - } -}