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