From af1c7a376ac69d0cd8c3c17b0dbe53cf2441d1cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=91=D0=B0=D0=BA=D0=B0?= =?UTF-8?q?=D0=BB=D1=8C=D1=81=D0=BA=D0=B0=D1=8F?= Date: Thu, 30 May 2024 09:36:16 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=D0=B0=20=D0=BF=D1=80=D0=B8=D0=B2=D1=8F=D0=B7=D0=BA=D1=83?= =?UTF-8?q?=20=D1=81=D0=B8=D0=BC=D0=BF=D1=82=D0=BE=D0=BC=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=B8=20=D0=BB=D0=B5=D0=BA=D0=B0=D1=80=D1=81=D1=82=D0=B2.=20?= =?UTF-8?q?=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D0=BE=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=85=D0=BE=D1=82=D1=8F=20=D0=B1=D1=8B=20=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D1=8C=20:/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/CoursesController.cs | 2 +- .../Controllers/HomeController.cs | 79 +++++++++++++++---- .../Models/AddSymptomToMedicamentModel.cs | 3 + .../Views/Home/AddSymptomToMedicament.cshtml | 27 ++++++- .../Views/Shared/_Layout.cshtml | 2 +- 5 files changed, 96 insertions(+), 17 deletions(-) diff --git a/Polyclinic/PolyclinicWebAppImplementer/Controllers/CoursesController.cs b/Polyclinic/PolyclinicWebAppImplementer/Controllers/CoursesController.cs index 4d92f34..d95da02 100644 --- a/Polyclinic/PolyclinicWebAppImplementer/Controllers/CoursesController.cs +++ b/Polyclinic/PolyclinicWebAppImplementer/Controllers/CoursesController.cs @@ -84,7 +84,7 @@ namespace PolyclinicWebAppImplementer.Controllers CourseViewModel = obj, Diagnoses = _diagnoseLogic.ReadList().Select(x => (x, obj.CourseDiagnoses.ContainsKey(x.Id))).ToList() }; - ViewData["Title"] = "Редактировать симптом"; + ViewData["Title"] = "Редактировать курс"; return View("CourseForm", model); } else diff --git a/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs b/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs index da7d6b2..2e198c3 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs +++ b/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs @@ -504,20 +504,7 @@ namespace PolyclinicWebAppSuretor.Controllers return RedirectToAction("Procedures"); } - public IActionResult AddSymptomToMedicament(AddSymptomToMedicamentModel model) - { - var currentUser = LoginManager.LogginedUser; - if (currentUser == null) - { - return RedirectToAction("Login", "Home"); - } - model = new() - { - Medicaments = _medicamentLogic.ReadList(null), - Symptoms = _symptomLogic.ReadList(null) - }; - return View(model); - } + public IActionResult ListCoursesByProcedures() { @@ -657,6 +644,70 @@ namespace PolyclinicWebAppSuretor.Controllers } } + [HttpGet] + [HttpPost] + public IActionResult AddSymptomToMedicament(AddSymptomToMedicamentModel model) + { + var currentUser = LoginManager.LogginedUser; + if (currentUser == null) + { + return RedirectToAction("Login", "Home"); + } + + var medicaments = _medicamentLogic.ReadList(null); + var symptomes = _symptomLogic.ReadList(); + var linkedMedicaments = medicaments + .Where(x => x.SymptomId != null) + .Select(x => (x, _symptomLogic.ReadElement(new SymptomSearchModel { Id = x.SymptomId }))).ToList(); + + if (HttpContext.Request.Method == "GET") + { + model = new() + { + Medicaments = medicaments, + Symptoms = symptomes, + LinkedMedicaments = linkedMedicaments + }; + + return View(model); + } + else + { + var medicament = _medicamentLogic.ReadElement(new MedicamentSearchModel { Id = model.MedicamentId }); + var medicamentBindingModel = new MedicamentBindingModel + { + Id = medicament.Id, + Name = medicament.Name, + Comment = medicament.Comment, + SymptomId = model.SymptomId, + ProcedureId = medicament.ProcedureId + }; + _medicamentLogic.Update(medicamentBindingModel); + return RedirectToAction("AddSymptomToMedicament"); + } + } + [HttpPost] + public IActionResult UnLinkCourse(int id) + { + var currentUser = LoginManager.LogginedUser; + if (currentUser == null) + { + return RedirectToAction("Login", "Home"); + } + + var medicament = _medicamentLogic.ReadElement(new MedicamentSearchModel { Id = id }); + var medicamentBindingModel = new MedicamentBindingModel + { + Id = medicament.Id, + Name = medicament.Name, + Comment = medicament.Comment, + //SymptomId = null, + ProcedureId = medicament.ProcedureId + }; + _medicamentLogic.Update(medicamentBindingModel); + return RedirectToAction("AddSymptomToMedicament"); + } + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { diff --git a/Polyclinic/PolyclinicWebAppSuretor/Models/AddSymptomToMedicamentModel.cs b/Polyclinic/PolyclinicWebAppSuretor/Models/AddSymptomToMedicamentModel.cs index bdc6f29..e2e1d46 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Models/AddSymptomToMedicamentModel.cs +++ b/Polyclinic/PolyclinicWebAppSuretor/Models/AddSymptomToMedicamentModel.cs @@ -6,5 +6,8 @@ namespace PolyclinicWebAppSuretor.Models { public List Medicaments { get; set; } = new(); public List Symptoms { get; set; } = new(); + public int? MedicamentId { get; set; } + public int? SymptomId { get; set;} + public List<(MedicamentViewModel medicament, SymptomViewModel symptom)> LinkedMedicaments { get; set; } = new(); } } diff --git a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/AddSymptomToMedicament.cshtml b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/AddSymptomToMedicament.cshtml index 1a2b363..46ba0bc 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/AddSymptomToMedicament.cshtml +++ b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/AddSymptomToMedicament.cshtml @@ -43,4 +43,29 @@ - \ No newline at end of file + + +
+

Привязанные симптомы

+ + + + + + + @foreach (var item in Model.LinkedMedicaments) + { + + + + + + } +
ЛекарствоСимптом
#@item.medicament.Id @item.medicament.Name#@item.symptom.Id @item.symptom.Name +
+ +
+
+
\ No newline at end of file diff --git a/Polyclinic/PolyclinicWebAppSuretor/Views/Shared/_Layout.cshtml b/Polyclinic/PolyclinicWebAppSuretor/Views/Shared/_Layout.cshtml index 773ea99..6840da0 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Views/Shared/_Layout.cshtml +++ b/Polyclinic/PolyclinicWebAppSuretor/Views/Shared/_Layout.cshtml @@ -55,7 +55,7 @@ {
@Html.RouteLink(LoginManager.LogginedUser.FIO, new { controller = "Home", action = "Privacy" }, new { @title = "Личный кабинет" }) -
+
-- 2.25.1