From b626bfda7d725f41aeeb5c5a38619276105f2cc6 Mon Sep 17 00:00:00 2001 From: dex_moth Date: Wed, 29 May 2024 17:25:32 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BA=D0=BE=D1=80=D0=BE=D1=87=D0=B5=20=D1=81?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B5=20=D0=BA=D0=B8=D0=BF=D0=B5=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComputerHardwareStoreREST/Program.cs | 2 +- .../Controllers/HomeController.cs | 39 +++++++++++++++++-- .../Views/Home/Register.cshtml | 2 +- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/ComputerHardwareStore/ComputerHardwareStoreREST/Program.cs b/ComputerHardwareStore/ComputerHardwareStoreREST/Program.cs index 46213d2..b1d43ad 100644 --- a/ComputerHardwareStore/ComputerHardwareStoreREST/Program.cs +++ b/ComputerHardwareStore/ComputerHardwareStoreREST/Program.cs @@ -32,6 +32,7 @@ builder.Services.AddTransient(); //builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient (); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); @@ -53,7 +54,6 @@ if (app.Environment.IsDevelopment()) app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "AbstractShopRestApi v1")); } -app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); diff --git a/ComputerHardwareStore/StoreKeeperClient/Controllers/HomeController.cs b/ComputerHardwareStore/StoreKeeperClient/Controllers/HomeController.cs index 70b20c8..231229a 100644 --- a/ComputerHardwareStore/StoreKeeperClient/Controllers/HomeController.cs +++ b/ComputerHardwareStore/StoreKeeperClient/Controllers/HomeController.cs @@ -23,7 +23,7 @@ namespace StoreKeeperClient.Controllers return Redirect("~/Home/Enter"); } - return View(APIClient.GetRequest>($"api/main/getpurchases?clientId={APIClient.Client.Id}")); + return View(APIClient.GetRequest>($"api/main/getpurchases?storekeeperId={APIClient.Client.Id}")); } [HttpGet] @@ -47,7 +47,7 @@ namespace StoreKeeperClient.Controllers { throw new Exception("Введите логин, пароль и ФИО"); } - APIClient.PostRequest("api/client/updatedata", new StoreKeeperBindingModel + APIClient.PostRequest("api/storekeeper/updatedata", new StoreKeeperBindingModel { Id = APIClient.Client.Id, Name = fio, @@ -66,13 +66,44 @@ namespace StoreKeeperClient.Controllers return View(); } + [HttpPost] + public void Enter(string login, string password) + { + if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password)) + { + throw new Exception("Введите почту и пароль"); + } + APIClient.Client = APIClient.GetRequest($"api/storekeeper/login?login={login}&password={password}"); + if (APIClient.Client == null) + { + throw new Exception("Неверные почта и/или пароль"); + } + Response.Redirect("Index"); + return; + } + [HttpGet] public IActionResult Register() { return View(); } - + [HttpPost] + public void Register(string name, string login, string password) + { + if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(password)) + { + throw new Exception("Введите логин, name, пароль"); + } + APIClient.PostRequest("api/storekeeper/register", new StoreKeeperBindingModel + { + Name = name, + Login = login, + Password = password, + }); + Response.Redirect("Enter"); + return; + } [HttpGet] public IActionResult AddBuildToPurchase() { @@ -239,7 +270,7 @@ namespace StoreKeeperClient.Controllers { return Redirect("~/Home/Enter"); } - return View(APIClient.GetRequest>($"api/client/getmessages?clientId={APIClient.Client.Id}")); + return View(APIClient.GetRequest>($"api/storekeeper/getmessages?storekeeperId={APIClient.Client.Id}")); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] diff --git a/ComputerHardwareStore/StoreKeeperClient/Views/Home/Register.cshtml b/ComputerHardwareStore/StoreKeeperClient/Views/Home/Register.cshtml index a12fd58..a230890 100644 --- a/ComputerHardwareStore/StoreKeeperClient/Views/Home/Register.cshtml +++ b/ComputerHardwareStore/StoreKeeperClient/Views/Home/Register.cshtml @@ -7,7 +7,7 @@
ФИО:
-
+
Логин: