diff --git a/Polyclinic/PolyclinicDatabaseImplement/Models/Procedure.cs b/Polyclinic/PolyclinicDatabaseImplement/Models/Procedure.cs index db2d496..7af3a39 100644 --- a/Polyclinic/PolyclinicDatabaseImplement/Models/Procedure.cs +++ b/Polyclinic/PolyclinicDatabaseImplement/Models/Procedure.cs @@ -36,10 +36,16 @@ namespace PolyclinicDatabaseImplement.Models }; } - public void Update(ProcedureBindingModel bindingModel) + public void Update(ProcedureBindingModel? bindingModel) { + if (bindingModel == null) + { + return; + } Name = bindingModel.Name; Comment = bindingModel.Comment; + DateStartProcedure = bindingModel.DateStartProcedure; + DateStopProcedure = bindingModel.DateStopProcedure; } public ProcedureViewModel GetViewModel => new() diff --git a/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs b/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs index 3b6289d..e226244 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs +++ b/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs @@ -78,25 +78,26 @@ namespace PolyclinicWebAppSuretor.Controllers return RedirectToAction("Procedures"); } } + [HttpGet] [HttpPost] - public IActionResult Edit(int id,string name, string comment, DateTime dateStart, DateTime? dateStop) + public IActionResult EditProcedure(ProcedureViewModel model) { if (HttpContext.Request.Method == "GET") { - var obj = _procedureLogic.ReadElement(new ProcedureSearchModel { Id = id }); + var obj = _procedureLogic.ReadElement(new ProcedureSearchModel { Id = model.Id }); ViewData["Title"] = " "; - return View(obj); + return View("CreateProcedure", obj); } else { ProcedureBindingModel procedure = new ProcedureBindingModel { - Id = id, - Name = name, - Comment = comment, - DateStartProcedure = dateStart, - DateStopProcedure = dateStop + Id = model.Id, + Name = model.Name, + Comment = model.Comment, + DateStartProcedure = model.DateStartProcedure, + DateStopProcedure = model.DateStopProcedure }; _procedureLogic.Update(procedure); return RedirectToAction("Procedures"); @@ -107,7 +108,7 @@ namespace PolyclinicWebAppSuretor.Controllers { return View(); } - + public IActionResult ListCoursesByProcedures() { return View(); @@ -117,7 +118,7 @@ namespace PolyclinicWebAppSuretor.Controllers { return View(); } - + [HttpGet] [HttpPost] public IActionResult ProceduresReport() diff --git a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateProcedure.cshtml b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateProcedure.cshtml index 16c094a..711e634 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateProcedure.cshtml +++ b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateProcedure.cshtml @@ -1,28 +1,26 @@ @using PolyclinicContracts.ViewModels @model ProcedureViewModel -@{ - ViewData["Title"] = "CreateProcedure"; -} +