добавила классы и представления для регистрации, логина, перечисления для отображения страниц в зависимости от состояния пользователя и тд
This commit is contained in:
parent
64558376ee
commit
74dd85bd7e
9
Polyclinic/PolyclinicWebAppSuretor/LoginManager.cs
Normal file
9
Polyclinic/PolyclinicWebAppSuretor/LoginManager.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using PolyclinicContracts.ViewModels;
|
||||
|
||||
namespace PolyclinicWebAppSuretor
|
||||
{
|
||||
public class LoginManager
|
||||
{
|
||||
public static UserViewModel? LogginedUser { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using PolyclinicDataModels.Enums;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace PolyclinicWebAppSuretor.Models
|
||||
{
|
||||
public class UserPrivacyModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Роль")]
|
||||
public UserRole Role { get; set; }
|
||||
}
|
||||
}
|
12
Polyclinic/PolyclinicWebAppSuretor/RestrictionEnum.cs
Normal file
12
Polyclinic/PolyclinicWebAppSuretor/RestrictionEnum.cs
Normal file
@ -0,0 +1,12 @@
|
||||
namespace PolyclinicWebAppSuretor
|
||||
{
|
||||
public class RestrictionEnum
|
||||
{
|
||||
public enum PageVisible
|
||||
{
|
||||
AllowAnyBody = 0,
|
||||
AllowOnlyAuthorized = 1,
|
||||
AllowOnlyNotAuthorized = 2,
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +1,23 @@
|
||||
namespace PolyclinicWebAppSuretor
|
||||
using static PolyclinicWebAppSuretor.RestrictionEnum;
|
||||
|
||||
namespace PolyclinicWebAppSuretor
|
||||
{
|
||||
public static class SiteMenuItems
|
||||
{
|
||||
public static (string Url, string Title) Index = ("", "Главная");
|
||||
public static (string Url, string Title) Medicaments = ("Medicaments", "Лекарства");
|
||||
public static (string Url, string Title) Procedures = ("Procedures", "Процедуры");
|
||||
public static (string Url, string Title) Recipes = ("Recipes", "Рецепты");
|
||||
public static (string Url, string Title) Login = ("Login", "Вход");
|
||||
public static (string Url, string Title) Register = ("Register", "Регистрация");
|
||||
public static (string Url, string Title) AddSymptomToMedicament = ("AddSymptomToMedicament", "Привязка симптома к лекарству");
|
||||
public static (string Url, string Title) ProceduresReport = ("ProceduresReport", "Отчет по процедурам");
|
||||
public static (string Url, string Title) ListCoursesByProcedures = ("ListCoursesByProcedures", "Список курсов приема препаратов");
|
||||
public static (string Url, string Title, PageVisible Visible) Index = ("", "Главная", PageVisible.AllowAnyBody);
|
||||
public static (string Url, string Title, PageVisible Visible) Medicaments = ("Medicaments", "Лекарства", PageVisible.AllowOnlyAuthorized);
|
||||
public static (string Url, string Title, PageVisible Visible) Procedures = ("Procedures", "Процедуры", PageVisible.AllowOnlyAuthorized);
|
||||
public static (string Url, string Title, PageVisible Visible) Recipes = ("Recipes", "Рецепты", PageVisible.AllowOnlyAuthorized);
|
||||
public static (string Url, string Title, PageVisible Visible) Login = ("Login", "Вход", PageVisible.AllowOnlyNotAuthorized);
|
||||
public static (string Url, string Title, PageVisible Visible) Register = ("Register", "Регистрация", PageVisible.AllowOnlyNotAuthorized);
|
||||
public static (string Url, string Title, PageVisible Visible) AddSymptomToMedicament = ("AddSymptomToMedicament", "Привязка симптома к лекарству", PageVisible.AllowOnlyAuthorized);
|
||||
public static (string Url, string Title, PageVisible Visible) ProceduresReport = ("ProceduresReport", "Отчет по процедурам", PageVisible.AllowOnlyAuthorized);
|
||||
public static (string Url, string Title, PageVisible Visible) ListCoursesByProcedures = ("ListCoursesByProcedures", "Список курсов приема препаратов", PageVisible.AllowOnlyAuthorized);
|
||||
public static (string Url, string Title, PageVisible Visible) Privacy = ("Privacy", "Личный кабинет", PageVisible.AllowOnlyAuthorized);
|
||||
|
||||
public static List<(string Url, string Title)> MenuItemsOrder = new List<(string Url, string Title)>
|
||||
public static List<(string Url, string Title, PageVisible Visible)> MenuItemsOrder = new List<(string Url, string Title, PageVisible Visible)>
|
||||
{
|
||||
Index, Medicaments, Procedures, Recipes, ListCoursesByProcedures, Login, Register, AddSymptomToMedicament, ProceduresReport
|
||||
Index, Medicaments, Procedures, Recipes, ListCoursesByProcedures, Login, Register, AddSymptomToMedicament, ProceduresReport, Privacy
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,16 @@
|
||||
@{
|
||||
@model LoginModel
|
||||
@{
|
||||
ViewBag.SelectedSiteMenuItem = SiteMenuItems.Login;
|
||||
}
|
||||
<div class="d-flex w-100 h-100 align-content-center justify-content-center align-items-center mt-5 pt-5">
|
||||
<form class="d-flex flex-column border border-primary border-3 rounded-3 p-5" id="loginForm" method="post">
|
||||
<h4>Вход</h4>
|
||||
@foreach (var item in Model.Errors)
|
||||
{
|
||||
<div class="alert alert-danger" role="alert">
|
||||
@item
|
||||
</div>
|
||||
}
|
||||
<div class="mb-2 row">
|
||||
<label for="emailInput" class="col-4 ps-0">
|
||||
Email
|
||||
|
@ -1,6 +1,38 @@
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
@model UserPrivacyModel
|
||||
@{
|
||||
ViewBag.SelectedSiteMenuItem = SiteMenuItems.Privacy;
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
<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>
|
||||
|
||||
<p>Use this page to detail your site's privacy policy.</p>
|
||||
|
@ -1,8 +1,16 @@
|
||||
@model RegisterModel
|
||||
|
||||
@{
|
||||
ViewBag.SelectedSiteMenuItem = SiteMenuItems.Register;
|
||||
}
|
||||
<div class="d-flex w-100 h-100 align-content-center justify-content-center align-items-center mt-5 pt-5">
|
||||
<form class="d-flex flex-column border border-success border-3 rounded-3 p-5" id="loginForm" method="post">
|
||||
<h4>Регистрация</h4>
|
||||
@foreach (var item in Model.Errors)
|
||||
{
|
||||
<div class="alert alert-danger" role="alert">
|
||||
@item
|
||||
</div>
|
||||
}
|
||||
<div class="d-flex mb-3">
|
||||
<label for="fioInput" class="pe-3 w-25">
|
||||
ФИО
|
||||
|
@ -1,26 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
@using static PolyclinicWebAppSuretor.RestrictionEnum
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
@if (ViewData.ContainsKey("Title"))
|
||||
{
|
||||
<title>
|
||||
@if (ViewData.ContainsKey("SelectedSiteMenuItem"))
|
||||
{
|
||||
@ViewBag.SelectedSiteMenuItem.Item2
|
||||
}
|
||||
else if (ViewData.ContainsKey("Title"))
|
||||
{
|
||||
@ViewData["Title"]
|
||||
}
|
||||
</title>
|
||||
}
|
||||
else
|
||||
{
|
||||
<title>Боликлиника</title>
|
||||
}
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/PolyclinicWebAppSuretor.styles.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/PolyclinicWebView.styles.css" asp-append-version="true" />
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<header class="sticky-top">
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">
|
||||
<img src="~/img/polyclinic_logo_mini.svg" height="30" alt="Logo" class="d-inline-block align-text-top">
|
||||
</a>
|
||||
<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">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
@ -28,6 +32,10 @@
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
@foreach (var menuItem in SiteMenuItems.MenuItemsOrder)
|
||||
{
|
||||
@if (menuItem.Visible == PageVisible.AllowAnyBody ||
|
||||
LoginManager.LogginedUser == null && menuItem.Visible == PageVisible.AllowOnlyNotAuthorized ||
|
||||
LoginManager.LogginedUser != null && menuItem.Visible == PageVisible.AllowOnlyAuthorized)
|
||||
{
|
||||
<li class="menu-item">
|
||||
@Html.RouteLink(menuItem.Title, new
|
||||
@ -41,7 +49,17 @@
|
||||
)
|
||||
</li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
@if (LoginManager.LogginedUser != null)
|
||||
{
|
||||
<div class="d-flex align-items-center">
|
||||
@Html.RouteLink(LoginManager.LogginedUser.FIO, new { controller = "User", action = "Privacy" }, new { @title = "Личный кабинет" })
|
||||
<form class="ms-3" method="post" asp-action="Logout" asp-controller="User">
|
||||
<button class="btn btn-secondary" type="submit">Выйти</button>
|
||||
</form>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@ -52,9 +70,9 @@
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<footer class="border-top footer text-muted">
|
||||
<footer class="border-top footer text-muted bg-light fixed-bottom">
|
||||
<div class="container">
|
||||
© 2024 - Поликлиника "Будьте больны" - <a asp-area="" asp-controller="Home" asp-action="Privacy">Политика конфедициальности</a>
|
||||
© 2024 - Поликлиника БудьтеБольны
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user