diff --git a/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs b/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs index 832d428..fd060dc 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs +++ b/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs @@ -1,5 +1,8 @@ using Microsoft.AspNetCore.Mvc; +using PolyclinicBusinessLogic.BusinessLogics; +using PolyclinicContracts.BindingModels; using PolyclinicContracts.BusinessLogicsContracts; +using PolyclinicContracts.SearchModels; using PolyclinicContracts.ViewModels; using PolyclinicWebAppSuretor.Models; using System.Diagnostics; @@ -52,9 +55,52 @@ namespace PolyclinicWebAppSuretor.Controllers return View(); } - public IActionResult CreateProcedure() + [HttpGet] + [HttpPost] + public IActionResult CreateProcedure(string name, string? comment, DateTime dateStart, DateTime? dateStop) { - return View(); + if (HttpContext.Request.Method == "GET") + { + ViewData["Title"] = " "; + return View(); + } + else + { + // TODO UserId + ProcedureBindingModel procedure = new ProcedureBindingModel + { + Name = name, + Comment = comment ?? string.Empty, + DateStartProcedure = dateStart, + DateStopProcedure = dateStop + }; + _procedureLogic.Create(procedure); + return RedirectToAction("Procedures"); + } + } + [HttpGet] + [HttpPost] + public IActionResult Edit(int id, string name, string comment, DateTime dateStart, DateTime? dateStop) + { + if (HttpContext.Request.Method == "GET") + { + var obj = _procedureLogic.ReadElement(new ProcedureSearchModel { Id = id }); + ViewData["Title"] = " "; + return View(obj); + } + else + { + ProcedureBindingModel procedure = new ProcedureBindingModel + { + Id = id, + Name = name, + Comment = comment ?? string.Empty, + DateStartProcedure = dateStart, + DateStopProcedure = dateStop + }; + _procedureLogic.Update(procedure); + return RedirectToAction("Procedures"); + } } public IActionResult CreateMedicament() diff --git a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateProcedure.cshtml b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateProcedure.cshtml index a9562a3..16c094a 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateProcedure.cshtml +++ b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateProcedure.cshtml @@ -1,5 +1,5 @@ @using PolyclinicContracts.ViewModels -@model List +@model ProcedureViewModel @{ ViewData["Title"] = "CreateProcedure"; } @@ -10,40 +10,38 @@
- +

Название:

- +

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

-
-
-
-
- +
\ No newline at end of file diff --git a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Procedures.cshtml b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Procedures.cshtml index 66cb332..2946c54 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Procedures.cshtml +++ b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Procedures.cshtml @@ -7,76 +7,58 @@

Процедуры

-
+
@{ // if (Model == null) // { //

Авторизируйтесь

// return; // } -

- Создать процедуру -

+ - - - - - - - + + + + + + + - @foreach (var item in Model) + + @foreach (var item in Model) { - - - - - - - + + + + + + + + + } +
- Номер - - Название процедуры - - Дата начала процедуры - - Дата окончания процедуры - - Комментарий - - Редактировать - - Удалить - НомерНазвание процедурыДата начала процедурыДата окончания процедурыКомментарийРедактироватьУдалить
- @Html.DisplayFor(modelItem => item.Id) - - @Html.DisplayFor(modelItem => item.Name) - - @Html.DisplayFor(modelItem => item.DateStartProcedure) - - @Html.DisplayFor(modelItem => item.DateStopProcedure) - - @Html.DisplayFor(modelItem => item.Comment) - - - - - - - - - - - - -
@Html.DisplayFor(modelItem => item.Id)@Html.DisplayFor(modelItem => item.Name)@Html.DisplayFor(modelItem => item.DateStartProcedure)@Html.DisplayFor(modelItem => item.DateStopProcedure)@Html.DisplayFor(modelItem => item.Comment) + + + + + + + + + + + +
}