sardq 2024-05-29 19:07:05 +04:00
commit 4b5d089fe1
4 changed files with 93 additions and 9 deletions

View File

@ -72,7 +72,6 @@ namespace FactoryDatabaseImplement.Models
{ {
return; return;
} }
Login = model.Login;
Email = model.Email; Email = model.Email;
Password = model.Password; Password = model.Password;
} }

View File

@ -101,6 +101,53 @@ namespace FactoryStorekeeperApp.Controllers
} }
[HttpGet] [HttpGet]
public IActionResult Privacy()
{
if (!IsLoggedIn)
{
return Redirect("~/Home/Enter");
}
return View(Client.client);
}
[HttpPost]
public IActionResult Privacy(string email, string password)
{
if (!IsLoggedIn)
{
return Unauthorized();
}
var existsClient = clientLogic.ReadElement(new ClientSearchModel
{
Id = Client.client.Id,
});
clientLogic.Update(new ClientBindingModel
{
Id = Client.client.Id,
Login = existsClient.Login,
Password = password,
Email = email,
});
var updatedClient = clientLogic.ReadElement(new ClientSearchModel
{
Id = Client.client.Id,
});
Client.client = updatedClient;
return Redirect("~/Home/Index");
}
[HttpPost]
public IActionResult Logout()
{
if (!IsLoggedIn)
{
return Unauthorized();
}
Client.client = null;
return Redirect("~/Home/Enter");
}
[HttpGet]
public IActionResult Machines() public IActionResult Machines()
{ {
if (!IsLoggedIn) if (!IsLoggedIn)

View File

@ -0,0 +1,29 @@
@using FactoryContracts.ViewModels
@{
ViewData["Title"] = "Профиль";
}
@model ClientViewModel
<div class="text-center">
<h2 class="display-4">Профиль кладовщика</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" id="login" value="@Model.Login" readonly disabled/></div>
</div>
<div class="row">
<div class="col-4">Почта:</div>
<div class="col-8"><input type="email" id="email" name="email" value="@Model.Email" /></div>
</div>
<div class="row">
<div class="col-4">Новый пароль:</div>
<div class="col-8"><input type="password" name="password" id="password" value="@Model.Password" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
</div>
</form>
<form asp-controller="Home" asp-action="Logout" method="post">
<button type="submit" class="btn btn-danger">Выйти из аккаунта</button>
</form>

View File

@ -13,21 +13,30 @@
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3"> <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container"> <div class="container">
<a class="navbar-brand" asp-area="" asp-page="/Index">Завод "Иди работать". Кладовщик</a> <a class="navbar-brand" asp-area="" asp-page="/Index">Завод "Иди работать". Кладовщик</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent" <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation"> aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between"> <div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1"> <ul class="navbar-nav flex-grow-1">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Главная</a> <a class="nav-link text-dark" asp-controller="Home" asp-action="Index">Главная</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Вход</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
</li> </li>
@if (Client.client != null){
<li class="nav-item">
<a class="nav-link text-dark" asp-controller="Home" asp-action="Privacy">Профиль</a>
</li>
}
else
{
<li class="nav-item">
<a class="nav-link text-dark" asp-controller="Home" asp-action="Enter">Вход</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-controller="Home" asp-action="Register">Регистрация</a>
</li>
}
</ul> </ul>
</div> </div>
</div> </div>