добавила классы и представления для регистрации, логина, перечисления для отображения страниц в зависимости от состояния пользователя и тд

This commit is contained in:
Елена Бакальская 2024-05-29 22:45:43 +04:00
parent 64558376ee
commit 74dd85bd7e
8 changed files with 145 additions and 43 deletions

View File

@ -0,0 +1,9 @@
using PolyclinicContracts.ViewModels;
namespace PolyclinicWebAppSuretor
{
public class LoginManager
{
public static UserViewModel? LogginedUser { get; set; }
}
}

View File

@ -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; }
}
}

View File

@ -0,0 +1,12 @@
namespace PolyclinicWebAppSuretor
{
public class RestrictionEnum
{
public enum PageVisible
{
AllowAnyBody = 0,
AllowOnlyAuthorized = 1,
AllowOnlyNotAuthorized = 2,
}
}
}

View File

@ -1,20 +1,23 @@
namespace PolyclinicWebAppSuretor using static PolyclinicWebAppSuretor.RestrictionEnum;
namespace PolyclinicWebAppSuretor
{ {
public static class SiteMenuItems public static class SiteMenuItems
{ {
public static (string Url, string Title) Index = ("", "Главная"); public static (string Url, string Title, PageVisible Visible) Index = ("", "Главная", PageVisible.AllowAnyBody);
public static (string Url, string Title) Medicaments = ("Medicaments", "Лекарства"); public static (string Url, string Title, PageVisible Visible) Medicaments = ("Medicaments", "Лекарства", PageVisible.AllowOnlyAuthorized);
public static (string Url, string Title) Procedures = ("Procedures", "Процедуры"); public static (string Url, string Title, PageVisible Visible) Procedures = ("Procedures", "Процедуры", PageVisible.AllowOnlyAuthorized);
public static (string Url, string Title) Recipes = ("Recipes", "Рецепты"); public static (string Url, string Title, PageVisible Visible) Recipes = ("Recipes", "Рецепты", PageVisible.AllowOnlyAuthorized);
public static (string Url, string Title) Login = ("Login", "Вход"); public static (string Url, string Title, PageVisible Visible) Login = ("Login", "Вход", PageVisible.AllowOnlyNotAuthorized);
public static (string Url, string Title) Register = ("Register", "Регистрация"); public static (string Url, string Title, PageVisible Visible) Register = ("Register", "Регистрация", PageVisible.AllowOnlyNotAuthorized);
public static (string Url, string Title) AddSymptomToMedicament = ("AddSymptomToMedicament", "Привязка симптома к лекарству"); public static (string Url, string Title, PageVisible Visible) AddSymptomToMedicament = ("AddSymptomToMedicament", "Привязка симптома к лекарству", PageVisible.AllowOnlyAuthorized);
public static (string Url, string Title) ProceduresReport = ("ProceduresReport", "Отчет по процедурам"); public static (string Url, string Title, PageVisible Visible) ProceduresReport = ("ProceduresReport", "Отчет по процедурам", PageVisible.AllowOnlyAuthorized);
public static (string Url, string Title) ListCoursesByProcedures = ("ListCoursesByProcedures", "Список курсов приема препаратов"); 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
}; };
} }
} }

View File

@ -1,9 +1,16 @@
@{ @model LoginModel
@{
ViewBag.SelectedSiteMenuItem = SiteMenuItems.Login; 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"> <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"> <form class="d-flex flex-column border border-primary border-3 rounded-3 p-5" id="loginForm" method="post">
<h4>Вход</h4> <h4>Вход</h4>
@foreach (var item in Model.Errors)
{
<div class="alert alert-danger" role="alert">
@item
</div>
}
<div class="mb-2 row"> <div class="mb-2 row">
<label for="emailInput" class="col-4 ps-0"> <label for="emailInput" class="col-4 ps-0">
Email Email

View File

@ -1,6 +1,38 @@
@{ @model UserPrivacyModel
ViewData["Title"] = "Privacy Policy"; @{
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>

View File

@ -1,8 +1,16 @@
@model RegisterModel @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"> <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"> <form class="d-flex flex-column border border-success border-3 rounded-3 p-5" id="loginForm" method="post">
<h4>Регистрация</h4> <h4>Регистрация</h4>
@foreach (var item in Model.Errors)
{
<div class="alert alert-danger" role="alert">
@item
</div>
}
<div class="d-flex mb-3"> <div class="d-flex mb-3">
<label for="fioInput" class="pe-3 w-25"> <label for="fioInput" class="pe-3 w-25">
ФИО ФИО

View File

@ -1,26 +1,30 @@
<!DOCTYPE html> @using static PolyclinicWebAppSuretor.RestrictionEnum
<!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title> @if (ViewData.ContainsKey("Title"))
@if (ViewData.ContainsKey("SelectedSiteMenuItem")) {
{ <title>
@ViewBag.SelectedSiteMenuItem.Item2
}
else if (ViewData.ContainsKey("Title"))
{
@ViewData["Title"] @ViewData["Title"]
} </title>
</title> }
else
{
<title>Боликлиника</title>
}
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" /> <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="~/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> </head>
<body> <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"> <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid"> <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" <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>
@ -29,19 +33,33 @@
<ul class="navbar-nav flex-grow-1"> <ul class="navbar-nav flex-grow-1">
@foreach (var menuItem in SiteMenuItems.MenuItemsOrder) @foreach (var menuItem in SiteMenuItems.MenuItemsOrder)
{ {
<li class="menu-item"> @if (menuItem.Visible == PageVisible.AllowAnyBody ||
@Html.RouteLink(menuItem.Title, new LoginManager.LogginedUser == null && menuItem.Visible == PageVisible.AllowOnlyNotAuthorized ||
{ LoginManager.LogginedUser != null && menuItem.Visible == PageVisible.AllowOnlyAuthorized)
controller = "Home", {
action = menuItem.Url <li class="menu-item">
}, new @Html.RouteLink(menuItem.Title, new
{ {
@class = "nav-link text-dark" + (menuItem.Equals(ViewBag.SelectedSiteMenuItem) ? " fw-bold" : "") controller = "Home",
} action = menuItem.Url
) }, new
</li> {
@class = "nav-link text-dark" + (menuItem.Equals(ViewBag.SelectedSiteMenuItem) ? " fw-bold" : "")
}
)
</li>
}
} }
</ul> </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>
</div> </div>
</nav> </nav>
@ -52,9 +70,9 @@
</main> </main>
</div> </div>
<footer class="border-top footer text-muted"> <footer class="border-top footer text-muted bg-light fixed-bottom">
<div class="container"> <div class="container">
&copy; 2024 - Поликлиника "Будьте больны" - <a asp-area="" asp-controller="Home" asp-action="Privacy">Политика конфедициальности</a> &copy; 2024 - Поликлиника БудьтеБольны
</div> </div>
</footer> </footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script> <script src="~/lib/jquery/dist/jquery.min.js"></script>