diff --git a/HardwareShop/HardwareShopClientApp/Controllers/HomeController.cs b/HardwareShop/HardwareShopClientApp/Controllers/HomeController.cs index 6a67040..bc76ab8 100644 --- a/HardwareShop/HardwareShopClientApp/Controllers/HomeController.cs +++ b/HardwareShop/HardwareShopClientApp/Controllers/HomeController.cs @@ -44,9 +44,40 @@ namespace HardwareShopStorekeeperApp.Controllers return View(); } + [HttpGet] public IActionResult Privacy() { - return View(); + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIClient.User); + } + + [HttpPost] + public void Privacy(string login, string email, string password) + { + if (APIClient.User == null) + { + throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); + } + if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) + { + throw new Exception("Введите логин, пароль и почту"); + } + APIClient.PostRequest("api/user/updatedata", new UserBindingModel + { + Id = APIClient.User.Id, + Login = login, + Email = email, + Password = password + }); + + APIClient.User.Login = login; + APIClient.User.Email = email; + APIClient.User.Password = password; + + RedirectToAction("MainStorekeeper", "Storekeeper"); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] diff --git a/HardwareShop/HardwareShopClientApp/Views/Home/Privacy.cshtml b/HardwareShop/HardwareShopClientApp/Views/Home/Privacy.cshtml new file mode 100644 index 0000000..1984ba8 --- /dev/null +++ b/HardwareShop/HardwareShopClientApp/Views/Home/Privacy.cshtml @@ -0,0 +1,29 @@ +@using HardwareShopContracts.ViewModels; + + +@model UserViewModel + +@{ + ViewData["Title"] = "Privacy Policy"; + Layout = "~/Views/Shared/_LayoutWorker.cshtml"; +} +