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 @@
- +
+ + + } + }