From 4f6a0ba0be2488b5f453fa6a715a366fb549366f 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: Mon, 27 May 2024 21:27:51 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB?= =?UTF-8?q?=D0=B0=20=D0=BA=D1=80=D1=83=D0=B4=D1=8B=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D1=86=D0=B5=D0=B4=D1=83=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 21 ++++++++++++++----- .../Views/Home/Procedures.cshtml | 19 ++++++++++------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs b/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs index e226244..86bdb98 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs +++ b/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs @@ -57,7 +57,7 @@ namespace PolyclinicWebAppSuretor.Controllers [HttpGet] [HttpPost] - public IActionResult CreateProcedure(string name, string? comment, DateTime dateStart, DateTime? dateStop) + public IActionResult CreateProcedure(ProcedureViewModel model) { if (HttpContext.Request.Method == "GET") { @@ -69,10 +69,10 @@ namespace PolyclinicWebAppSuretor.Controllers // TODO прописать UserId ProcedureBindingModel procedure = new ProcedureBindingModel { - Name = name, - Comment = comment ?? string.Empty, - DateStartProcedure = dateStart, - DateStopProcedure = dateStop + Name = model.Name, + Comment = model.Comment ?? string.Empty, + DateStartProcedure = model.DateStartProcedure, + DateStopProcedure = model.DateStopProcedure }; _procedureLogic.Create(procedure); return RedirectToAction("Procedures"); @@ -104,6 +104,17 @@ namespace PolyclinicWebAppSuretor.Controllers } } + [HttpPost] + public IActionResult DeleteProcedure(int id) + { + var obj = _procedureLogic.ReadElement(new ProcedureSearchModel { Id = id }); + if (obj != null) + { + _procedureLogic.Delete(new ProcedureBindingModel { Id = obj.Id }); + } + return RedirectToAction("Procedures"); + } + public IActionResult CreateMedicament() { return View(); diff --git a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Procedures.cshtml b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Procedures.cshtml index cd79321..7e0b10f 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Procedures.cshtml +++ b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Procedures.cshtml @@ -37,7 +37,7 @@ @foreach (var item in Model) { - @Html.DisplayFor(modelItem => item.Id) + @item.Id @item.Name @item.DateStartProcedure.ToShortDateString() @item.DateStopProcedure?.ToShortDateString() @@ -50,13 +50,16 @@ - - - - - - - +
+ + +