From f6c5157c5dbd5c5c74679bd1fdcc0be96f531a8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Mon, 15 May 2023 18:59:57 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D1=8B=D1=82=D0=BA=D0=B8=20?= =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=D0=B8=D1=82=D1=8C=20=D1=80=D0=B5=D0=B3?= =?UTF-8?q?=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=86=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HardwareShopDatabase.cs | 2 +- HardwareShop/HardwareShopRestApi/Program.cs | 2 +- .../Controllers/HomeController.cs | 14 +++++++++++--- .../HardwareShopWorkerApp.csproj | 1 + .../HardwareShopWorkerApp/appsettings.json | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs b/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs index 36bfb0d..ba1c28d 100644 --- a/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs +++ b/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs @@ -10,7 +10,7 @@ namespace HardwareShopDatabaseImplement { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - optionsBuilder.UseNpgsql("Host=localhost;Port=5433;Database=Computer_Hardware_Store;Username=user;Password=12345"); + optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=Computer_Hardware_Store;Username=postgres;Password=1234"); AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); } diff --git a/HardwareShop/HardwareShopRestApi/Program.cs b/HardwareShop/HardwareShopRestApi/Program.cs index 0139832..6053db8 100644 --- a/HardwareShop/HardwareShopRestApi/Program.cs +++ b/HardwareShop/HardwareShopRestApi/Program.cs @@ -35,7 +35,7 @@ builder.Services.AddControllers(); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(c => { - c.SwaggerDoc("v1", new OpenApiInfo { Title = "SushiBarRestApi", Version = "v1" }); + c.SwaggerDoc("v1", new OpenApiInfo { Title = "HardwareShopRestApi", Version = "v1" }); }); var app = builder.Build(); diff --git a/HardwareShop/HardwareShopWorkerApp/Controllers/HomeController.cs b/HardwareShop/HardwareShopWorkerApp/Controllers/HomeController.cs index 5f9f0a2..6970d98 100644 --- a/HardwareShop/HardwareShopWorkerApp/Controllers/HomeController.cs +++ b/HardwareShop/HardwareShopWorkerApp/Controllers/HomeController.cs @@ -22,13 +22,21 @@ namespace HardwareShopWorkerApp.Controllers } [HttpPost] - public void Register(string login, string email, string password, int role) + public void Register(string login, string email, string password) { - if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password) || role <= 0) + if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) { - throw new Exception("Введите логин, email, пароль и роль"); + throw new Exception("Введите логин, email, пароль"); } + APIClient.PostRequest("api/client/register", new UserBindingModel + { + Login = login, + Email = email, + Password = password, + Role = UserRole.Работник, + }); Response.Redirect("Enter"); + return; } public IActionResult Index() diff --git a/HardwareShop/HardwareShopWorkerApp/HardwareShopWorkerApp.csproj b/HardwareShop/HardwareShopWorkerApp/HardwareShopWorkerApp.csproj index 39a8038..003939b 100644 --- a/HardwareShop/HardwareShopWorkerApp/HardwareShopWorkerApp.csproj +++ b/HardwareShop/HardwareShopWorkerApp/HardwareShopWorkerApp.csproj @@ -23,6 +23,7 @@ + diff --git a/HardwareShop/HardwareShopWorkerApp/appsettings.json b/HardwareShop/HardwareShopWorkerApp/appsettings.json index 6d1c8cd..8685b00 100644 --- a/HardwareShop/HardwareShopWorkerApp/appsettings.json +++ b/HardwareShop/HardwareShopWorkerApp/appsettings.json @@ -7,5 +7,5 @@ }, "AllowedHosts": "*", - "IPAddress": "http://localhost:5008/" + "IPAddress": "http://localhost:5254/" }