From 48dd09518213e1a8432a50749a38797fb8d2656c 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: Tue, 28 May 2024 00:17:46 +0400 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=D0=B0=20?= =?UTF-8?q?=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=B5?= =?UTF-8?q?=D0=B4=D0=B8=D0=BA=D0=B0=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20?= =?UTF-8?q?(=D0=B1=D0=B5=D0=B7=20=D1=81=D0=B8=D0=BC=D0=BF=D1=82=D0=BE?= =?UTF-8?q?=D0=BC=D0=BE=D0=B2),=20=D0=BC=D1=83=D1=87=D0=B0=D1=8E=D1=81?= =?UTF-8?q?=D1=8C=20=D1=81=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=D0=BC=20=D1=80=D0=B5=D1=86=D0=B5=D0=BF=D1=82=D0=BE=D0=B2?= =?UTF-8?q?...=20=D0=BC=D0=BD=D0=BE=D0=B3=D0=B8=D0=B5=20=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=BC=D0=BD=D0=BE=D0=B3=D0=B8=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BindingModels/RecipeBindingModel.cs | 2 +- .../Controllers/HomeController.cs | 169 ++++++++++++++++-- Polyclinic/PolyclinicWebAppSuretor/Program.cs | 9 + .../Views/Home/CreateMedicament.cshtml | 41 ++--- .../Views/Home/CreateRecipe.cshtml | 51 +++--- .../Views/Home/Medicaments.cshtml | 34 ++-- .../Views/Home/Procedures.cshtml | 2 +- .../Views/Home/Recipes.cshtml | 52 +++--- 8 files changed, 247 insertions(+), 113 deletions(-) diff --git a/Polyclinic/PolyclinicContracts/BindingModels/RecipeBindingModel.cs b/Polyclinic/PolyclinicContracts/BindingModels/RecipeBindingModel.cs index 1e92b18..5511c58 100644 --- a/Polyclinic/PolyclinicContracts/BindingModels/RecipeBindingModel.cs +++ b/Polyclinic/PolyclinicContracts/BindingModels/RecipeBindingModel.cs @@ -8,6 +8,6 @@ namespace PolyclinicContracts.BindingModels public int? CourseId { get; set; } public int ProceduresCount { get; set; } public string Comment { get; set; } = string.Empty; - public Dictionary RecipeProcedures { get; } = new(); + public Dictionary RecipeProcedures { get; set; } = new(); } } \ No newline at end of file diff --git a/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs b/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs index 86bdb98..60fe2f9 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs +++ b/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs @@ -13,11 +13,21 @@ namespace PolyclinicWebAppSuretor.Controllers { private readonly ILogger _logger; private readonly IProcedureLogic _procedureLogic; + private readonly IMedicamentLogic _medicamentLogic; + private readonly IRecipeLogic _recipeLogic; + private readonly ISymptomLogic _symptomLogic; - public HomeController(ILogger logger, IProcedureLogic procedureLogic) + public HomeController(ILogger logger, + IProcedureLogic procedureLogic, + IMedicamentLogic medicamentLogic, + IRecipeLogic recipeLogic, + ISymptomLogic symptomLogic) { _logger = logger; _procedureLogic = procedureLogic; + _medicamentLogic = medicamentLogic; + _recipeLogic = recipeLogic; + _symptomLogic = symptomLogic; } public IActionResult Index() @@ -30,11 +40,151 @@ namespace PolyclinicWebAppSuretor.Controllers return View(); } + public IActionResult Recipes() + { + List recipes = _recipeLogic.ReadList(null); + if (recipes == null) + { + recipes = new(); + } + return View(recipes); + } + + [HttpGet] + [HttpPost] + public IActionResult CreateRecipe(RecipeViewModel model) + { + ViewBag.Procedures = _procedureLogic.ReadList(null); + ViewBag.RecipeProcedures = _recipeLogic. + if (HttpContext.Request.Method == "GET") + { + ViewData["Title"] = " "; + return View(); + } + else + { + // TODO UserId + RecipeBindingModel recipe = new RecipeBindingModel + { + Comment = model.Comment, + CourseId = model.CourseId, + ProceduresCount = model.ProceduresCount, + RecipeProcedures = model.RecipeProcedures + }; + _recipeLogic.Create(recipe); + return RedirectToAction("Medicaments"); + } + } + + [HttpGet] + [HttpPost] + public IActionResult EditRecipe(MedicamentViewModel model) + { + if (HttpContext.Request.Method == "GET") + { + var obj = _medicamentLogic.ReadElement(new MedicamentSearchModel { Id = model.Id }); + ViewData["Title"] = " "; + return View("CreateMedicament", obj); + } + else + { + MedicamentBindingModel medicament = new MedicamentBindingModel + { + Id = model.Id, + Name = model.Name, + Comment = model.Comment ?? string.Empty, + SymptomId = model.SymptomId, + ProcedureId = model.ProcedureId, + }; + _medicamentLogic.Update(medicament); + return RedirectToAction("Medicaments"); + } + } + + [HttpPost] + public IActionResult DeleteRecipe(int id) + { + var obj = _medicamentLogic.ReadElement(new MedicamentSearchModel { Id = id }); + if (obj != null) + { + _medicamentLogic.Delete(new MedicamentBindingModel { Id = obj.Id }); + } + return RedirectToAction("Medicaments"); + } + public IActionResult Medicaments() { - return View(); + List medicaments = _medicamentLogic.ReadList(null); + if (medicaments == null) + { + medicaments = new(); + } + return View(medicaments); } + [HttpGet] + [HttpPost] + public IActionResult CreateMedicament(MedicamentViewModel model) + { + ViewBag.Procedures = _procedureLogic.ReadList(null); + ViewBag.Symptomes = _symptomLogic.ReadList(null); + if (HttpContext.Request.Method == "GET") + { + ViewData["Title"] = " "; + return View(); + } + else + { + // TODO UserId + MedicamentBindingModel medicament = new MedicamentBindingModel + { + Name = model.Name, + Comment = model.Comment ?? string.Empty, + SymptomId = model.SymptomId, + ProcedureId = model.ProcedureId, + }; + _medicamentLogic.Create(medicament); + return RedirectToAction("Medicaments"); + } + } + + [HttpGet] + [HttpPost] + public IActionResult EditMedicament(MedicamentViewModel model) + { + if (HttpContext.Request.Method == "GET") + { + var obj = _medicamentLogic.ReadElement(new MedicamentSearchModel { Id = model.Id }); + ViewData["Title"] = " "; + return View("CreateMedicament", obj); + } + else + { + MedicamentBindingModel medicament = new MedicamentBindingModel + { + Id = model.Id, + Name = model.Name, + Comment = model.Comment ?? string.Empty, + SymptomId = model.SymptomId, + ProcedureId = model.ProcedureId, + }; + _medicamentLogic.Update(medicament); + return RedirectToAction("Medicaments"); + } + } + + [HttpPost] + public IActionResult DeleteMedicament(int id) + { + var obj = _medicamentLogic.ReadElement(new MedicamentSearchModel { Id = id }); + if (obj != null) + { + _medicamentLogic.Delete(new MedicamentBindingModel { Id = obj.Id }); + } + return RedirectToAction("Medicaments"); + } + + public IActionResult Procedures() { List procedure = _procedureLogic.ReadList(null); @@ -45,16 +195,6 @@ namespace PolyclinicWebAppSuretor.Controllers return View(procedure); } - public IActionResult Recipes() - { - return View(); - } - - public IActionResult CreateRecipe() - { - return View(); - } - [HttpGet] [HttpPost] public IActionResult CreateProcedure(ProcedureViewModel model) @@ -115,11 +255,6 @@ namespace PolyclinicWebAppSuretor.Controllers return RedirectToAction("Procedures"); } - public IActionResult CreateMedicament() - { - return View(); - } - public IActionResult ListCoursesByProcedures() { return View(); diff --git a/Polyclinic/PolyclinicWebAppSuretor/Program.cs b/Polyclinic/PolyclinicWebAppSuretor/Program.cs index e5c6330..d66e48c 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Program.cs +++ b/Polyclinic/PolyclinicWebAppSuretor/Program.cs @@ -17,6 +17,15 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); + +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); + + var app = builder.Build(); // Configure the HTTP request pipeline. diff --git a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateMedicament.cshtml b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateMedicament.cshtml index d2823fa..0029f80 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateMedicament.cshtml +++ b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateMedicament.cshtml @@ -1,10 +1,9 @@ @using PolyclinicContracts.ViewModels -@model List -@{ - ViewData["Title"] = "CreateMedicament"; -} +@model MedicamentViewModel + +
-

Создание препарата

+

@ViewData["Title"]

@@ -15,14 +14,14 @@

Название:

- +

Комментарий:

- @@ -32,14 +31,12 @@

Выбор процедуры:

- + + @foreach (var procedure in ViewBag.Procedures) + { + } @@ -50,13 +47,11 @@

Выбор симптома:

- + + @foreach (var symptom in ViewBag.Symptomes) + { + }
@@ -64,7 +59,7 @@
- +
\ No newline at end of file diff --git a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateRecipe.cshtml b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateRecipe.cshtml index 962e879..69434ab 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateRecipe.cshtml +++ b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateRecipe.cshtml @@ -1,10 +1,10 @@ @using PolyclinicContracts.ViewModels -@model List +@model RecipeViewModel @{ - ViewData["Title"] = "CreateRecipe"; + }
-

Создание рецепта

+

@ViewData["Title"]

@@ -15,14 +15,14 @@

Количество процедур:

- +

Комментарий:

- @@ -32,14 +32,11 @@

Выбор процедуры:

- + + @foreach (var item in ViewBag.Procedures) + { + }
@@ -55,21 +52,19 @@ - @{ - int cRows = 20; - for (int i = 1; i <= cRows; i++) - { - - Процедура № @i - - - - - - - - - } + @foreach (var item in ViewBag.RecipeProcedures) + { + + Процедура № @item.Id @item.Name + + + + + + + + + } diff --git a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Medicaments.cshtml b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Medicaments.cshtml index bbb787d..4df7240 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Medicaments.cshtml +++ b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Medicaments.cshtml @@ -1,8 +1,6 @@ @using PolyclinicContracts.ViewModels @model List -@{ - ViewData["Title"] = "Medicaments"; -} +@ViewData["Title"] = "Medicaments";

Препараты

@@ -31,7 +29,7 @@ Симптом - Рецепт (номер) + Процедура Комментарий @@ -49,26 +47,28 @@ { @item.Id @item.Name - @item.SymptomId. + @item.SymptomName + @item.ProcedureName + @item.Comment - 3 - - - При особом неврозе употребляйте каждый день и спина не будет болеть - - - + - - - - - + + + + + } diff --git a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Procedures.cshtml b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Procedures.cshtml index 609bb50..e21072c 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Procedures.cshtml +++ b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Procedures.cshtml @@ -49,7 +49,7 @@
- +
+ + + } + }