From 1e02a06b49afc84fb09edf671571a30cb21abfc2 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Mon, 27 May 2024 22:23:44 +0400 Subject: [PATCH 1/3] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DiagnosesController.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Polyclinic/PolyclinicWebAppImplementer/Controllers/DiagnosesController.cs b/Polyclinic/PolyclinicWebAppImplementer/Controllers/DiagnosesController.cs index c7b7c13..2eb18fc 100644 --- a/Polyclinic/PolyclinicWebAppImplementer/Controllers/DiagnosesController.cs +++ b/Polyclinic/PolyclinicWebAppImplementer/Controllers/DiagnosesController.cs @@ -55,6 +55,7 @@ namespace PolyclinicWebAppImplementer.Controllers [HttpPost] public IActionResult Edit(int id, DiagnoseViewModel model) { + // TODO проверить, что пользователь зочет редактировать свой диагноз (UserId) if (HttpContext.Request.Method == "GET") { var obj = _diagnoseLogic.ReadElement(new DiagnoseSearchModel { Id = id }); From 19f7fbb7f4019bcc8810e95de04fd6496e5e0d71 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Mon, 27 May 2024 22:30:16 +0400 Subject: [PATCH 2/3] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DiagnosesController.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Polyclinic/PolyclinicWebAppImplementer/Controllers/DiagnosesController.cs b/Polyclinic/PolyclinicWebAppImplementer/Controllers/DiagnosesController.cs index 2eb18fc..0793cbb 100644 --- a/Polyclinic/PolyclinicWebAppImplementer/Controllers/DiagnosesController.cs +++ b/Polyclinic/PolyclinicWebAppImplementer/Controllers/DiagnosesController.cs @@ -55,7 +55,7 @@ namespace PolyclinicWebAppImplementer.Controllers [HttpPost] public IActionResult Edit(int id, DiagnoseViewModel model) { - // TODO проверить, что пользователь зочет редактировать свой диагноз (UserId) + // TODO проверить, что пользователь хочет редактировать свой диагноз (UserId) if (HttpContext.Request.Method == "GET") { var obj = _diagnoseLogic.ReadElement(new DiagnoseSearchModel { Id = id }); @@ -80,6 +80,7 @@ namespace PolyclinicWebAppImplementer.Controllers [HttpPost] public IActionResult Delete(int id) { + // TODO проверить, что пользователь хочет удалить свой диагноз (UserId) var obj = _diagnoseLogic.ReadElement(new DiagnoseSearchModel { Id = id }); if (obj != null) { From d747d42272972cc66cec770581900aa257d34a2d Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Tue, 28 May 2024 00:27:17 +0400 Subject: [PATCH 3/3] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BD=D1=82=D1=80=D0=BE=D0=BB=D0=BB=D0=B5=D1=80?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D1=81=D0=B8=D0=BC=D0=BF=D1=82=D0=BE?= =?UTF-8?q?=D0=BC=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/SymptomesController.cs | 78 +++++++++++++++++++ .../PolyclinicWebAppImplementer.csproj | 2 +- .../SymptomForm.cshtml} | 11 ++- .../SymptomesList.cshtml} | 2 +- 4 files changed, 85 insertions(+), 8 deletions(-) create mode 100644 Polyclinic/PolyclinicWebAppImplementer/Controllers/SymptomesController.cs rename Polyclinic/PolyclinicWebAppImplementer/Views/{Home/Symptom.cshtml => Symptomes/SymptomForm.cshtml} (89%) rename Polyclinic/PolyclinicWebAppImplementer/Views/{Home/Symptomes.cshtml => Symptomes/SymptomesList.cshtml} (95%) diff --git a/Polyclinic/PolyclinicWebAppImplementer/Controllers/SymptomesController.cs b/Polyclinic/PolyclinicWebAppImplementer/Controllers/SymptomesController.cs new file mode 100644 index 0000000..9b10fdd --- /dev/null +++ b/Polyclinic/PolyclinicWebAppImplementer/Controllers/SymptomesController.cs @@ -0,0 +1,78 @@ +using Microsoft.AspNetCore.Mvc; +using PolyclinicContracts.BindingModels; +using PolyclinicContracts.BusinessLogicsContracts; +using PolyclinicContracts.SearchModels; +using PolyclinicContracts.ViewModels; + +namespace PolyclinicWebAppImplementer.Controllers +{ + public class SymptomesController : Controller + { + private readonly ISymptomLogic _symptomLogic; + private readonly IDiagnoseLogic _diagnoseLogic; + public SymptomesController(ISymptomLogic symptomLogic, IDiagnoseLogic diagnoseLogic) + { + _symptomLogic = symptomLogic; + _diagnoseLogic = diagnoseLogic; + } + [HttpGet] + public IActionResult Index() + { + List symptomes = _symptomLogic.ReadList(); + ViewData["Title"] = "Список симптомов"; + return View("SymptomesList", symptomes); + } + [HttpGet] + [HttpPost] + public IActionResult Add(SymptomViewModel model) + { + if (HttpContext.Request.Method == "GET") + { + ViewData["Title"] = "Новый симптом"; + return View("SymptomForm"); + } + else + { + SymptomBindingModel symptom = new SymptomBindingModel + { + Name = model.Name, + Comment = model.Comment, + }; + _symptomLogic.Create(symptom); + return RedirectToAction("Index"); + } + } + [HttpGet] + [HttpPost] + public IActionResult Edit(int id, SymptomViewModel model) + { + if (HttpContext.Request.Method == "GET") + { + var obj = _symptomLogic.ReadElement(new SymptomSearchModel { Id = id }); + ViewData["Title"] = "Редактировать симптом"; + return View("SymptomForm", obj); + } + else + { + SymptomBindingModel symptom = new SymptomBindingModel + { + Id = model.Id, + Name = model.Name, + Comment = model.Comment, + }; + _symptomLogic.Update(symptom); + return RedirectToAction("Index"); + } + } + [HttpPost] + public IActionResult Delete(int id) + { + var obj = _symptomLogic.ReadElement(new SymptomSearchModel { Id = id }); + if (obj != null) + { + _symptomLogic.Delete(new SymptomBindingModel { Id = obj.Id }); + } + return RedirectToAction("Index"); + } + } +} diff --git a/Polyclinic/PolyclinicWebAppImplementer/PolyclinicWebAppImplementer.csproj b/Polyclinic/PolyclinicWebAppImplementer/PolyclinicWebAppImplementer.csproj index 849878b..9a5a213 100644 --- a/Polyclinic/PolyclinicWebAppImplementer/PolyclinicWebAppImplementer.csproj +++ b/Polyclinic/PolyclinicWebAppImplementer/PolyclinicWebAppImplementer.csproj @@ -22,7 +22,7 @@ true PreserveNewest - + true PreserveNewest diff --git a/Polyclinic/PolyclinicWebAppImplementer/Views/Home/Symptom.cshtml b/Polyclinic/PolyclinicWebAppImplementer/Views/Symptomes/SymptomForm.cshtml similarity index 89% rename from Polyclinic/PolyclinicWebAppImplementer/Views/Home/Symptom.cshtml rename to Polyclinic/PolyclinicWebAppImplementer/Views/Symptomes/SymptomForm.cshtml index 52689f3..14c5e23 100644 --- a/Polyclinic/PolyclinicWebAppImplementer/Views/Home/Symptom.cshtml +++ b/Polyclinic/PolyclinicWebAppImplementer/Views/Symptomes/SymptomForm.cshtml @@ -1,15 +1,14 @@ -@{ - ViewBag.SelectedSiteMenuItem = SiteMenuItems.Symptom; -} -

Новый симптом

+@using PolyclinicContracts.ViewModels +@model SymptomViewModel +

@ViewData["Title"]

Название:
-
+
Коментарий:
-
+
diff --git a/Polyclinic/PolyclinicWebAppImplementer/Views/Home/Symptomes.cshtml b/Polyclinic/PolyclinicWebAppImplementer/Views/Symptomes/SymptomesList.cshtml similarity index 95% rename from Polyclinic/PolyclinicWebAppImplementer/Views/Home/Symptomes.cshtml rename to Polyclinic/PolyclinicWebAppImplementer/Views/Symptomes/SymptomesList.cshtml index d899370..0c4a41c 100644 --- a/Polyclinic/PolyclinicWebAppImplementer/Views/Home/Symptomes.cshtml +++ b/Polyclinic/PolyclinicWebAppImplementer/Views/Symptomes/SymptomesList.cshtml @@ -3,7 +3,7 @@ }