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 = "Личный кабинет" }) -
+