From 879a6536bc8d756f5b1fb52901426d56b688871f Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sat, 25 May 2024 20:31:18 +0400 Subject: [PATCH] Add registration and privacy update for managers --- .../Controllers/HomeController.cs | 60 +++++++++++++++++-- .../Views/Home/Privacy.cshtml | 19 +++++- .../Views/Home/Register.cshtml | 28 +++++++++ .../Views/Shared/_Layout.cshtml | 4 ++ .../Controllers/ManagerController.cs | 32 +++++++++- 5 files changed, 132 insertions(+), 11 deletions(-) create mode 100644 Bank/BankManagersClientApp/Views/Home/Register.cshtml diff --git a/Bank/BankManagersClientApp/Controllers/HomeController.cs b/Bank/BankManagersClientApp/Controllers/HomeController.cs index f4b3a58..08b5f1a 100644 --- a/Bank/BankManagersClientApp/Controllers/HomeController.cs +++ b/Bank/BankManagersClientApp/Controllers/HomeController.cs @@ -26,6 +26,60 @@ namespace BankManagersClientApp.Controllers return View(APIClient.Client); } + [HttpPost] + public void Privacy(string login, string password, string fio) + { + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) + { + throw new Exception("Введите логин, пароль и ФИО"); + } + APIClient.PostRequest("api/manager/updatemanager", new ManagerBindingModel + { + Id = APIClient.Client.Id, + Fio = fio, + Email = login, + Password = password + }); + APIClient.Client.Fio = fio; + APIClient.Client.Email = login; + APIClient.Client.Password = password; + Response.Redirect("Index"); + } + + [HttpGet] + public IActionResult Register() + { + return View(); + } + + [HttpPost] + public void Register(string login, string password, string fio) + { + if (string.IsNullOrEmpty(login) || + string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) + { + throw new Exception("Введите логин, пароль и ФИО"); + } + APIClient.PostRequest("api/manager/createmanager", new ManagerBindingModel + { + Fio = fio, + Email = login, + Password = password + }); + Response.Redirect("Enter"); + return; + } + + [HttpGet] + public IActionResult Enter() + { + return View(); + } + [HttpPost] public void Enter(string login, string password) { @@ -41,12 +95,6 @@ namespace BankManagersClientApp.Controllers } Response.Redirect("Index"); } - - [HttpGet] - public IActionResult Enter() - { - return View(); - } #endregion #region//Accounts diff --git a/Bank/BankManagersClientApp/Views/Home/Privacy.cshtml b/Bank/BankManagersClientApp/Views/Home/Privacy.cshtml index 2689d5c..7bb4064 100644 --- a/Bank/BankManagersClientApp/Views/Home/Privacy.cshtml +++ b/Bank/BankManagersClientApp/Views/Home/Privacy.cshtml @@ -6,19 +6,32 @@

Личные данные

-
+
Логин:
+ value="@Model.Email" /> +
+
+
+
Пароль:
+
+
ФИО:
+ value="@Model.Fio" /> +
+
+
+
+
+
diff --git a/Bank/BankManagersClientApp/Views/Home/Register.cshtml b/Bank/BankManagersClientApp/Views/Home/Register.cshtml new file mode 100644 index 0000000..f27c970 --- /dev/null +++ b/Bank/BankManagersClientApp/Views/Home/Register.cshtml @@ -0,0 +1,28 @@ +@{ + ViewData["Title"] = "Register"; +} + +
+

Регистрация

+
+
+
+
Логин:
+
+
+
+
Пароль:
+
+
+
+
ФИО:
+
+
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/Bank/BankManagersClientApp/Views/Shared/_Layout.cshtml b/Bank/BankManagersClientApp/Views/Shared/_Layout.cshtml index bf277bb..0ba610d 100644 --- a/Bank/BankManagersClientApp/Views/Shared/_Layout.cshtml +++ b/Bank/BankManagersClientApp/Views/Shared/_Layout.cshtml @@ -25,6 +25,10 @@ + + diff --git a/Bank/BankRestApi/Controllers/ManagerController.cs b/Bank/BankRestApi/Controllers/ManagerController.cs index 8cf42e0..897502c 100644 --- a/Bank/BankRestApi/Controllers/ManagerController.cs +++ b/Bank/BankRestApi/Controllers/ManagerController.cs @@ -37,6 +37,34 @@ namespace BankRestApi.Controllers _logger.LogError(ex, "Ошибка входа в систему"); throw; } - } - } + } + + [HttpPost] + public void CreateManager(ManagerBindingModel model) + { + try + { + _logic.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания менеджера"); + throw; + } + } + + [HttpPost] + public void UpdateManager(ManagerBindingModel model) + { + try + { + _logic.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка обновления менеджера"); + throw; + } + } + } }