From 7b94e137ad8c4c1d948c090bfe60709775e21f30 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Wed, 29 May 2024 14:16:10 +0400 Subject: [PATCH 1/3] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B1=D0=BE=D0=BB=D0=B5=D0=B7=D0=BD=D0=B5=D0=B9?= =?UTF-8?q?=20=D0=B2=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0=D1=85=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BA=D1=83=D1=80=D1=81=D0=BE=D0=B2=20=D0=B8=20?= =?UTF-8?q?=D1=81=D0=B8=D0=BC=D0=BF=D1=82=D0=BE=D0=BC=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/Courses/CourseForm.cshtml | 12 ++++++++++++ .../Views/Symptomes/SymptomForm.cshtml | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Polyclinic/PolyclinicWebAppImplementer/Views/Courses/CourseForm.cshtml b/Polyclinic/PolyclinicWebAppImplementer/Views/Courses/CourseForm.cshtml index 413be66..fabf0b0 100644 --- a/Polyclinic/PolyclinicWebAppImplementer/Views/Courses/CourseForm.cshtml +++ b/Polyclinic/PolyclinicWebAppImplementer/Views/Courses/CourseForm.cshtml @@ -17,6 +17,18 @@
    @foreach (var item in Model.Diagnoses) { + @if (LoginManager.LogginedUser.Id != item.Diagnose.UserId) + { + @if (item.IsChecked) + { + + } + else + { + + } + continue; + }
  1. @if (item.IsChecked) { diff --git a/Polyclinic/PolyclinicWebAppImplementer/Views/Symptomes/SymptomForm.cshtml b/Polyclinic/PolyclinicWebAppImplementer/Views/Symptomes/SymptomForm.cshtml index aa4b38e..7a2d556 100644 --- a/Polyclinic/PolyclinicWebAppImplementer/Views/Symptomes/SymptomForm.cshtml +++ b/Polyclinic/PolyclinicWebAppImplementer/Views/Symptomes/SymptomForm.cshtml @@ -14,6 +14,18 @@
      @foreach (var item in Model.Diagnoses) { + @if (LoginManager.LogginedUser.Id != item.Diagnose.UserId) + { + @if (item.IsChecked) + { + + } + else + { + + } + continue; + }
    1. @if (item.IsChecked) { From bcd851627ee573ba171b2bc07b5c290b5de94fcd Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Wed, 29 May 2024 14:23:16 +0400 Subject: [PATCH 2/3] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D1=88=D0=B0=D0=B1=D0=BB=D0=BE=D0=BD=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BB=D0=B8=D1=87=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BA=D0=B0=D0=B1?= =?UTF-8?q?=D0=B8=D0=BD=D0=B5=D1=82=D0=B0=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/UserController.cs | 11 +++++++++++ .../PolyclinicWebAppImplementer/SiteMenuItems.cs | 2 +- .../Views/Home/Privacy.cshtml | 6 ------ .../Views/Shared/_Layout.cshtml | 3 +-- .../Views/User/Privacy.cshtml | 6 ++++++ 5 files changed, 19 insertions(+), 9 deletions(-) delete mode 100644 Polyclinic/PolyclinicWebAppImplementer/Views/Home/Privacy.cshtml create mode 100644 Polyclinic/PolyclinicWebAppImplementer/Views/User/Privacy.cshtml diff --git a/Polyclinic/PolyclinicWebAppImplementer/Controllers/UserController.cs b/Polyclinic/PolyclinicWebAppImplementer/Controllers/UserController.cs index 3748432..2e5021a 100644 --- a/Polyclinic/PolyclinicWebAppImplementer/Controllers/UserController.cs +++ b/Polyclinic/PolyclinicWebAppImplementer/Controllers/UserController.cs @@ -94,5 +94,16 @@ namespace PolyclinicWebAppImplementer.Controllers LoginManager.LogginedUser = null; return RedirectToAction("Login"); } + + [HttpGet] + [HttpPost] + public IActionResult Privacy() + { + if (LoginManager.LogginedUser == null) + { + return RedirectToAction("Login"); + } + return View(); + } } } diff --git a/Polyclinic/PolyclinicWebAppImplementer/SiteMenuItems.cs b/Polyclinic/PolyclinicWebAppImplementer/SiteMenuItems.cs index 70b305a..4d1e0b3 100644 --- a/Polyclinic/PolyclinicWebAppImplementer/SiteMenuItems.cs +++ b/Polyclinic/PolyclinicWebAppImplementer/SiteMenuItems.cs @@ -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) 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) 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) MedicamentsByDiagnoses = ("Home", "MedicamentsByDiagnoses", "Лекарства по болезням", PageVisible.AllowOnlyAuthorized); public static (string Controller, string Action, string Title, PageVisible Visible) DiagnosesReport = ("Home", "DiagnosesReport", "Отчет по болезням", PageVisible.AllowOnlyAuthorized); diff --git a/Polyclinic/PolyclinicWebAppImplementer/Views/Home/Privacy.cshtml b/Polyclinic/PolyclinicWebAppImplementer/Views/Home/Privacy.cshtml deleted file mode 100644 index ce65fcc..0000000 --- a/Polyclinic/PolyclinicWebAppImplementer/Views/Home/Privacy.cshtml +++ /dev/null @@ -1,6 +0,0 @@ -@{ - ViewBag.SelectedSiteMenuItem = SiteMenuItems.Privacy; -} -

      Политика приватности

      - -

      Здесь нет никакой приватности

      diff --git a/Polyclinic/PolyclinicWebAppImplementer/Views/Shared/_Layout.cshtml b/Polyclinic/PolyclinicWebAppImplementer/Views/Shared/_Layout.cshtml index 3550179..70f67e7 100644 --- a/Polyclinic/PolyclinicWebAppImplementer/Views/Shared/_Layout.cshtml +++ b/Polyclinic/PolyclinicWebAppImplementer/Views/Shared/_Layout.cshtml @@ -71,8 +71,7 @@ diff --git a/Polyclinic/PolyclinicWebAppImplementer/Views/User/Privacy.cshtml b/Polyclinic/PolyclinicWebAppImplementer/Views/User/Privacy.cshtml new file mode 100644 index 0000000..5eb56c8 --- /dev/null +++ b/Polyclinic/PolyclinicWebAppImplementer/Views/User/Privacy.cshtml @@ -0,0 +1,6 @@ +@{ + ViewBag.SelectedSiteMenuItem = SiteMenuItems.Privacy; +} +

      Личный кабинет

      + +

      Здесь будут данные пользователя

      From f36d9c8d1d01852508e574a3cbb47d607954c5d3 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Wed, 29 May 2024 14:53:23 +0400 Subject: [PATCH 3/3] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=20=D0=BB=D0=B8=D1=87=D0=BD=D1=8B=D0=B9=20=D0=BA=D0=B0?= =?UTF-8?q?=D0=B1=D0=B8=D0=BD=D0=B5=D1=82=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Models/User.cs | 2 - .../Controllers/UserController.cs | 48 +++++++++++++++++-- .../Models/RegisterModel.cs | 8 +++- .../Models/UserPrivacyModel.cs | 12 +++++ .../Views/User/Privacy.cshtml | 36 +++++++++++++- 5 files changed, 98 insertions(+), 8 deletions(-) create mode 100644 Polyclinic/PolyclinicWebAppImplementer/Models/UserPrivacyModel.cs diff --git a/Polyclinic/PolyclinicDatabaseImplement/Models/User.cs b/Polyclinic/PolyclinicDatabaseImplement/Models/User.cs index 4773dc6..a2fe135 100644 --- a/Polyclinic/PolyclinicDatabaseImplement/Models/User.cs +++ b/Polyclinic/PolyclinicDatabaseImplement/Models/User.cs @@ -43,8 +43,6 @@ namespace PolyclinicDatabaseImplement.Models FIO = model.FIO; Email = model.Email; Password = model.Password; - Role = model.Role; - FIO = model.FIO; } public UserViewModel GetViewModel => new() diff --git a/Polyclinic/PolyclinicWebAppImplementer/Controllers/UserController.cs b/Polyclinic/PolyclinicWebAppImplementer/Controllers/UserController.cs index 2e5021a..3253da8 100644 --- a/Polyclinic/PolyclinicWebAppImplementer/Controllers/UserController.cs +++ b/Polyclinic/PolyclinicWebAppImplementer/Controllers/UserController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Microsoft.IdentityModel.Tokens; using PolyclinicContracts.BindingModels; using PolyclinicContracts.BusinessLogicsContracts; using PolyclinicContracts.SearchModels; @@ -97,13 +98,54 @@ namespace PolyclinicWebAppImplementer.Controllers [HttpGet] [HttpPost] - public IActionResult Privacy() + public IActionResult Privacy(UserPrivacyModel model) { - if (LoginManager.LogginedUser == null) + var currentUser = LoginManager.LogginedUser; + if (currentUser == null) { return RedirectToAction("Login"); } - return View(); + if (HttpContext.Request.Method == "POST") + { + var errors = new List(); + 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); + } } } } diff --git a/Polyclinic/PolyclinicWebAppImplementer/Models/RegisterModel.cs b/Polyclinic/PolyclinicWebAppImplementer/Models/RegisterModel.cs index 21b10da..888e7b3 100644 --- a/Polyclinic/PolyclinicWebAppImplementer/Models/RegisterModel.cs +++ b/Polyclinic/PolyclinicWebAppImplementer/Models/RegisterModel.cs @@ -1,10 +1,16 @@ -namespace PolyclinicWebAppImplementer.Models +using System.ComponentModel; + +namespace PolyclinicWebAppImplementer.Models { public class RegisterModel { + [DisplayName("ФИО")] public string FIO { get; set; } = string.Empty; + [DisplayName("Email")] public string Email { get; set; } = string.Empty; + [DisplayName("Пароль")] public string Password { get; set; } = string.Empty; + [DisplayName("Повторите пароль")] public string ConfirmPassword { get; set; } = string.Empty; public List Errors { get; set; } = new(); } diff --git a/Polyclinic/PolyclinicWebAppImplementer/Models/UserPrivacyModel.cs b/Polyclinic/PolyclinicWebAppImplementer/Models/UserPrivacyModel.cs new file mode 100644 index 0000000..5fe99e2 --- /dev/null +++ b/Polyclinic/PolyclinicWebAppImplementer/Models/UserPrivacyModel.cs @@ -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; } + } +} diff --git a/Polyclinic/PolyclinicWebAppImplementer/Views/User/Privacy.cshtml b/Polyclinic/PolyclinicWebAppImplementer/Views/User/Privacy.cshtml index 5eb56c8..789f612 100644 --- a/Polyclinic/PolyclinicWebAppImplementer/Views/User/Privacy.cshtml +++ b/Polyclinic/PolyclinicWebAppImplementer/Views/User/Privacy.cshtml @@ -1,6 +1,38 @@ -@{ +@model UserPrivacyModel +@{ ViewBag.SelectedSiteMenuItem = SiteMenuItems.Privacy; }

      Личный кабинет

      +@foreach (var item in Model.Errors) +{ + +} +
      + +
      + + +
      +
      + + +
      +
      + + +
      +
      + + +
      +
      + + +
      + +
      -

      Здесь будут данные пользователя