Merge branch 'stage9_10' of https://git.is.ulstu.ru/ns.potapov/PIbd-21_CourseWork_Polyclinic_BeSick into stage9_10
This commit is contained in:
commit
1c68c684c6
@ -43,8 +43,6 @@ namespace PolyclinicDatabaseImplement.Models
|
|||||||
FIO = model.FIO;
|
FIO = model.FIO;
|
||||||
Email = model.Email;
|
Email = model.Email;
|
||||||
Password = model.Password;
|
Password = model.Password;
|
||||||
Role = model.Role;
|
|
||||||
FIO = model.FIO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserViewModel GetViewModel => new()
|
public UserViewModel GetViewModel => new()
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using PolyclinicContracts.BindingModels;
|
using PolyclinicContracts.BindingModels;
|
||||||
using PolyclinicContracts.BusinessLogicsContracts;
|
using PolyclinicContracts.BusinessLogicsContracts;
|
||||||
using PolyclinicContracts.SearchModels;
|
using PolyclinicContracts.SearchModels;
|
||||||
@ -94,5 +95,57 @@ namespace PolyclinicWebAppImplementer.Controllers
|
|||||||
LoginManager.LogginedUser = null;
|
LoginManager.LogginedUser = null;
|
||||||
return RedirectToAction("Login");
|
return RedirectToAction("Login");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult Privacy(UserPrivacyModel model)
|
||||||
|
{
|
||||||
|
var currentUser = LoginManager.LogginedUser;
|
||||||
|
if (currentUser == null)
|
||||||
|
{
|
||||||
|
return RedirectToAction("Login");
|
||||||
|
}
|
||||||
|
if (HttpContext.Request.Method == "POST")
|
||||||
|
{
|
||||||
|
var errors = new List<string>();
|
||||||
|
var checkedUser = _userLogic.ReadElement(new UserSearchModel { Email = model.Email });
|
||||||
|
if (checkedUser != null && checkedUser.Id != LoginManager.LogginedUser.Id)
|
||||||
|
{
|
||||||
|
errors.Add("Пользователь с таким Email уже есть");
|
||||||
|
}
|
||||||
|
if (model.Password != model.ConfirmPassword)
|
||||||
|
{
|
||||||
|
errors.Add("Пароли не совпадают");
|
||||||
|
}
|
||||||
|
if (errors.Count > 0)
|
||||||
|
{
|
||||||
|
model.Errors = errors;
|
||||||
|
model.Password = string.Empty;
|
||||||
|
model.ConfirmPassword = string.Empty;
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
var user = new UserBindingModel
|
||||||
|
{
|
||||||
|
Id = currentUser.Id,
|
||||||
|
FIO = model.FIO,
|
||||||
|
Email = model.Email,
|
||||||
|
Password = model.Password.IsNullOrEmpty() ? LoginManager.LogginedUser.Password : model.Password,
|
||||||
|
};
|
||||||
|
_userLogic.Update(user);
|
||||||
|
LoginManager.LogginedUser = _userLogic.ReadElement(new UserSearchModel { Id = model.Id });
|
||||||
|
return RedirectToAction("Privacy");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
model = new()
|
||||||
|
{
|
||||||
|
Id = currentUser.Id,
|
||||||
|
FIO = currentUser.FIO,
|
||||||
|
Email = currentUser.Email,
|
||||||
|
Role = currentUser.Role
|
||||||
|
};
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
namespace PolyclinicWebAppImplementer.Models
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace PolyclinicWebAppImplementer.Models
|
||||||
{
|
{
|
||||||
public class RegisterModel
|
public class RegisterModel
|
||||||
{
|
{
|
||||||
|
[DisplayName("ФИО")]
|
||||||
public string FIO { get; set; } = string.Empty;
|
public string FIO { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Email")]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Пароль")]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Повторите пароль")]
|
||||||
public string ConfirmPassword { get; set; } = string.Empty;
|
public string ConfirmPassword { get; set; } = string.Empty;
|
||||||
public List<string> Errors { get; set; } = new();
|
public List<string> Errors { get; set; } = new();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
using PolyclinicDataModels.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace PolyclinicWebAppImplementer.Models
|
||||||
|
{
|
||||||
|
public class UserPrivacyModel : RegisterModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("Роль")]
|
||||||
|
public UserRole Role { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@
|
|||||||
public static (string Controller, string Action, string Title, PageVisible Visible) Symptomes = ("Symptomes", "", "Симптомы", PageVisible.AllowOnlyAuthorized);
|
public static (string Controller, string Action, string Title, PageVisible Visible) Symptomes = ("Symptomes", "", "Симптомы", PageVisible.AllowOnlyAuthorized);
|
||||||
public static (string Controller, string Action, string Title, PageVisible Visible) Login = ("User", "Login", "Вход", PageVisible.AllowOnlyNotAuthorized);
|
public static (string Controller, string Action, string Title, PageVisible Visible) Login = ("User", "Login", "Вход", PageVisible.AllowOnlyNotAuthorized);
|
||||||
public static (string Controller, string Action, string Title, PageVisible Visible) Register = ("User", "Register", "Регистрация", PageVisible.AllowOnlyNotAuthorized);
|
public static (string Controller, string Action, string Title, PageVisible Visible) Register = ("User", "Register", "Регистрация", PageVisible.AllowOnlyNotAuthorized);
|
||||||
public static (string Controller, string Action, string Title, PageVisible Visible) Privacy = ("Home", "Privacy", "Политика приватности", PageVisible.AllowAnyBody);
|
public static (string Controller, string Action, string Title, PageVisible Visible) Privacy = ("User", "Privacy", "Личный кабинет", PageVisible.AllowOnlyAuthorized);
|
||||||
public static (string Controller, string Action, string Title, PageVisible Visible) AddRecipeToCourse = ("Home", "AddRecipeToCourse", "Привязка рецепта", PageVisible.AllowOnlyAuthorized);
|
public static (string Controller, string Action, string Title, PageVisible Visible) AddRecipeToCourse = ("Home", "AddRecipeToCourse", "Привязка рецепта", PageVisible.AllowOnlyAuthorized);
|
||||||
public static (string Controller, string Action, string Title, PageVisible Visible) MedicamentsByDiagnoses = ("Home", "MedicamentsByDiagnoses", "Лекарства по болезням", PageVisible.AllowOnlyAuthorized);
|
public static (string Controller, string Action, string Title, PageVisible Visible) MedicamentsByDiagnoses = ("Home", "MedicamentsByDiagnoses", "Лекарства по болезням", PageVisible.AllowOnlyAuthorized);
|
||||||
public static (string Controller, string Action, string Title, PageVisible Visible) DiagnosesReport = ("Home", "DiagnosesReport", "Отчет по болезням", PageVisible.AllowOnlyAuthorized);
|
public static (string Controller, string Action, string Title, PageVisible Visible) DiagnosesReport = ("Home", "DiagnosesReport", "Отчет по болезням", PageVisible.AllowOnlyAuthorized);
|
||||||
|
@ -17,6 +17,18 @@
|
|||||||
<ol>
|
<ol>
|
||||||
@foreach (var item in Model.Diagnoses)
|
@foreach (var item in Model.Diagnoses)
|
||||||
{
|
{
|
||||||
|
@if (LoginManager.LogginedUser.Id != item.Diagnose.UserId)
|
||||||
|
{
|
||||||
|
@if (item.IsChecked)
|
||||||
|
{
|
||||||
|
<input type="checkbox" hidden id="diagnose-@item.Diagnose.Id" name="selectedDiagnoses" value="@item.Diagnose.Id" checked />
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<input type="checkbox" hidden id="diagnose-@item.Diagnose.Id" name="selectedDiagnoses" value="@item.Diagnose.Id" />
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
<li class="mb-2 ps-1 ms-1">
|
<li class="mb-2 ps-1 ms-1">
|
||||||
@if (item.IsChecked)
|
@if (item.IsChecked)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
@{
|
|
||||||
ViewBag.SelectedSiteMenuItem = SiteMenuItems.Privacy;
|
|
||||||
}
|
|
||||||
<h1>Политика приватности</h1>
|
|
||||||
|
|
||||||
<p>Здесь нет никакой приватности</p>
|
|
@ -71,8 +71,7 @@
|
|||||||
|
|
||||||
<footer class="border-top footer text-muted bg-light fixed-bottom">
|
<footer class="border-top footer text-muted bg-light fixed-bottom">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
© 2024 - Поликлиника БудьтеБольны - <a asp-area="" asp-controller="Home" asp-action="Privacy">Политика конфиденциалности</a>
|
© 2024 - Поликлиника БудьтеБольны</div>
|
||||||
</div>
|
|
||||||
</footer>
|
</footer>
|
||||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
@ -14,6 +14,18 @@
|
|||||||
<ol>
|
<ol>
|
||||||
@foreach (var item in Model.Diagnoses)
|
@foreach (var item in Model.Diagnoses)
|
||||||
{
|
{
|
||||||
|
@if (LoginManager.LogginedUser.Id != item.Diagnose.UserId)
|
||||||
|
{
|
||||||
|
@if (item.IsChecked)
|
||||||
|
{
|
||||||
|
<input type="checkbox" hidden id="diagnose-@item.Diagnose.Id" name="selectedDiagnoses" value="@item.Diagnose.Id" checked />
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<input type="checkbox" hidden id="diagnose-@item.Diagnose.Id" name="selectedDiagnoses" value="@item.Diagnose.Id" />
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
<li class="mb-2 ps-1 ms-1">
|
<li class="mb-2 ps-1 ms-1">
|
||||||
@if (item.IsChecked)
|
@if (item.IsChecked)
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
@model UserPrivacyModel
|
||||||
|
@{
|
||||||
|
ViewBag.SelectedSiteMenuItem = SiteMenuItems.Privacy;
|
||||||
|
}
|
||||||
|
<h4>Личный кабинет</h4>
|
||||||
|
@foreach (var item in Model.Errors)
|
||||||
|
{
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
@item
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<form method="post">
|
||||||
|
<input hidden readonly asp-for="Id"/>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label asp-for="FIO"></label>
|
||||||
|
<input required asp-for="FIO" />
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label asp-for="Email"></label>
|
||||||
|
<input required asp-for="Email" />
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label asp-for="Role"></label>
|
||||||
|
<input readonly asp-for="Role" />
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label asp-for="Password"></label>
|
||||||
|
<input type="password" asp-for="Password" />
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label asp-for="ConfirmPassword"></label>
|
||||||
|
<input type="password" asp-for="ConfirmPassword" />
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-secondary" type="submit">
|
||||||
|
Применить
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user