diff --git a/Polyclinic/PolyclinicWebAppImplementer/Controllers/DiagnosesController.cs b/Polyclinic/PolyclinicWebAppImplementer/Controllers/DiagnosesController.cs index c7b7c13..0793cbb 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 }); @@ -79,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) { 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 @@ }