редактирование

This commit is contained in:
dasha 2023-05-19 15:49:30 +04:00
parent c15757969f
commit 2f80dcf920
5 changed files with 68 additions and 8 deletions

View File

@ -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)]

View File

@ -0,0 +1,29 @@
@using HardwareShopContracts.ViewModels;
@model UserViewModel
@{
ViewData["Title"] = "Privacy Policy";
Layout = "~/Views/Shared/_LayoutWorker.cshtml";
}
<div class="text-center">
<h2 class="display-4">Личные данные</h2>
</div>
<form method="post" class="d-flex flex-column align-items-center">
<div class="col-sm-3">
<label class="form-label">Почта:</label>
<input type="text" class="form-control" name="email" value="@Model.Email">
</div>
<div class="col-sm-3">
<label class="form-label">Пароль:</label>
<input type="text" class="form-control" name="password" value="@Model.Password">
</div>
<div class="col-sm-3">
<label class="form-label">Логин:</label>
<input type="text" class="form-control" name="login" value="@Model.Login">
</div>
<div class="col-sm-2 d-flex justify-content-evenly align-items-baseline">
<button type="submit" class="btn btn-primary mt-3 px-4">Подтвердить</button>
</div>
</form>

View File

@ -76,7 +76,7 @@ namespace HardwareShopWorkerApp.Controllers
}
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
{
throw new Exception("Введите логин, пароль и ФИО");
throw new Exception("Введите логин, пароль и почту");
}
APIClient.PostRequest("api/user/updatedata", new UserBindingModel
{
@ -111,7 +111,7 @@ namespace HardwareShopWorkerApp.Controllers
throw new Exception("Введите почту и пароль");
}
APIClient.User = APIClient.GetRequest<UserViewModel>($"api/user/login?email={email}&password={password}");
if (APIClient.User == null)
if (APIClient.User == null || APIClient.User.Role != UserRole.Работник)
{
throw new Exception("Неверные почта и/или пароль");
}

View File

@ -71,12 +71,12 @@
<div class="modal-content">
<form method="post" asp-controller="home" asp-action="CreateBuild">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Создание сборку</h5>
<h5 class="modal-title" id="exampleModalLabel">Создание сборки</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Name</label>
<label>Название</label>
<input type="text" class="form-control" required="required" name="name" />
</div>
</div>

View File

@ -17,9 +17,9 @@
<h2 class="display-4">Покупки</h2>
<p>
<a asp-controller="Home" asp-action="CreatePurchase" class="btn btn-primary mx-2">Добавить</a>
<button type="button" class="btn btn-primary mx-2" id="delete">Удалить покупку</button>
<button type="button" class="btn btn-primary mx-2" id="done">Выдан</button>
<button type="button" class="btn btn-primary mx-2" id="update">Изменить</button>
<button type="button" class="btn btn-primary mx-2" id="delete">Удалить</button>
<button type="button" class="btn btn-primary mx-2" id="done">Выдан</button>
</p>
</div>
<div class="text-center">