поправила даты и редактирование процедур

This commit is contained in:
Елена Бакальская 2024-05-27 19:09:14 +04:00
parent 13ecdcaecc
commit bd594232f9
4 changed files with 38 additions and 30 deletions

View File

@ -36,10 +36,16 @@ namespace PolyclinicDatabaseImplement.Models
}; };
} }
public void Update(ProcedureBindingModel bindingModel) public void Update(ProcedureBindingModel? bindingModel)
{ {
if (bindingModel == null)
{
return;
}
Name = bindingModel.Name; Name = bindingModel.Name;
Comment = bindingModel.Comment; Comment = bindingModel.Comment;
DateStartProcedure = bindingModel.DateStartProcedure;
DateStopProcedure = bindingModel.DateStopProcedure;
} }
public ProcedureViewModel GetViewModel => new() public ProcedureViewModel GetViewModel => new()

View File

@ -78,25 +78,26 @@ namespace PolyclinicWebAppSuretor.Controllers
return RedirectToAction("Procedures"); return RedirectToAction("Procedures");
} }
} }
[HttpGet] [HttpGet]
[HttpPost] [HttpPost]
public IActionResult Edit(int id,string name, string comment, DateTime dateStart, DateTime? dateStop) public IActionResult EditProcedure(ProcedureViewModel model)
{ {
if (HttpContext.Request.Method == "GET") if (HttpContext.Request.Method == "GET")
{ {
var obj = _procedureLogic.ReadElement(new ProcedureSearchModel { Id = id }); var obj = _procedureLogic.ReadElement(new ProcedureSearchModel { Id = model.Id });
ViewData["Title"] = "Ðåäàêòèðîâàòü ïðîöåäóðó"; ViewData["Title"] = "Ðåäàêòèðîâàòü ïðîöåäóðó";
return View(obj); return View("CreateProcedure", obj);
} }
else else
{ {
ProcedureBindingModel procedure = new ProcedureBindingModel ProcedureBindingModel procedure = new ProcedureBindingModel
{ {
Id = id, Id = model.Id,
Name = name, Name = model.Name,
Comment = comment, Comment = model.Comment,
DateStartProcedure = dateStart, DateStartProcedure = model.DateStartProcedure,
DateStopProcedure = dateStop DateStopProcedure = model.DateStopProcedure
}; };
_procedureLogic.Update(procedure); _procedureLogic.Update(procedure);
return RedirectToAction("Procedures"); return RedirectToAction("Procedures");

View File

@ -1,28 +1,26 @@
@using PolyclinicContracts.ViewModels @using PolyclinicContracts.ViewModels
@model ProcedureViewModel @model ProcedureViewModel
@{
ViewData["Title"] = "CreateProcedure";
}
<div class="text-center mt-3 mb-3"> <div class="text-center mt-3 mb-3">
<h2 class="display-4">Создание процедуры</h2> <h3>@ViewData["Title"]</h3>
</div> </div>
<form method="post" class="form-create-procedure d-flex flex-row justify-content-around align-items-center"> <form method="post" class="form-create-procedure d-flex flex-row justify-content-around align-items-center">
<div class="procedure-info d-flex flex-column mb-5 mt-5"> <div class="procedure-info d-flex flex-column mb-5 mt-5">
<input type="hidden" name="id" readonly asp-for="Id" /> <input type="hidden" readonly asp-for="Id" />
<div class="d-flex flex-row mb-5 flex-row justify-content-between align-items-center"> <div class="d-flex flex-row mb-5 flex-row justify-content-between align-items-center">
<h3 class="col-3 m-3"> <h3 class="col-3 m-3">
Название: Название:
</h3> </h3>
<input required type="text" id="name" name="name" asp-for="Name" /> <input required type="text" asp-for="Name" />
</div> </div>
<div class="d-flex flex-row mb-5 flex-row justify-content-between align-items-center"> <div class="d-flex flex-row mb-5 flex-row justify-content-between align-items-center">
<h3 class="col-3 m-3"> <h3 class="col-3 m-3">
Комментарий: Комментарий:
</h3> </h3>
<textarea type="text" id="comment" name="comment" asp-for="Comment" style="width: 45vh"> <textarea type="text" asp-for="Comment" style="width: 45vh">
</textarea> </textarea>
</div> </div>
</div> </div>
@ -32,13 +30,13 @@
<label for="dateStart" class="me-3"> <label for="dateStart" class="me-3">
Дата начала Дата начала
</label> </label>
<input type="date" id="dateStart" name="dateStart" asp-for="DateStartProcedure" /> <input type="date" id="dateStart" asp-for="DateStartProcedure" />
</div> </div>
<div class="mb-5 me-3"> <div class="mb-5 me-3">
<label for="dateStop" class="me-3"> <label for="dateStop" class="me-3">
Дата завершения Дата завершения
</label> </label>
<input type="date" id="dateStop" name="dateStop" asp-for="DateStopProcedure" /> <input type="date" id="dateStop" asp-for="DateStopProcedure" />
</div> </div>
<div class="col-4"> <div class="col-4">
<input type="submit" value="Сохранить" class="button-save-procedure btn" /> <input type="submit" value="Сохранить" class="button-save-procedure btn" />

View File

@ -38,23 +38,26 @@
{ {
<tr> <tr>
<td scope="row">@Html.DisplayFor(modelItem => item.Id)</td> <td scope="row">@Html.DisplayFor(modelItem => item.Id)</td>
<td>@Html.DisplayFor(modelItem => item.Name)</td> <td>@item.Name</td>
<td>@Html.DisplayFor(modelItem => item.DateStartProcedure)</td> <td>@item.DateStartProcedure.ToShortDateString()</td>
<td>@Html.DisplayFor(modelItem => item.DateStopProcedure)</td> <td>@item.DateStopProcedure?.ToShortDateString()</td>
<td>@Html.DisplayFor(modelItem => item.Comment)</td> <td>@item.Comment</td>
<td> <td>
<a asp-action="CreateProcedure"> <a asp-action="EditProcedure" asp-route-id="@item.Id">
<svg class="bi-edit-pen" viewBox="0 0 127 127" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg class="bi-edit-pen" viewBox="0 0 127 127" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M105.5 26L37 114.5C34.5 117 16.3 121.7 7.5 122.5C79.1 34.1 101 5.5 102 4C104.833 4.5 119.3 14.6 122.5 21C105 44 98.5 55 111.5 58.5" stroke="#008315" stroke-width="6" stroke-linecap="round" /> <path d="M105.5 26L37 114.5C34.5 117 16.3 121.7 7.5 122.5C79.1 34.1 101 5.5 102 4C104.833 4.5 119.3 14.6 122.5 21C105 44 98.5 55 111.5 58.5" stroke="#008315" stroke-width="6" stroke-linecap="round" />
</svg> </svg>
</a> </a>
</td> </td>
<td> <td>
<a asp-action="DeleteProcedure">
<svg class="bi-cart-delete" viewBox="0 0 154 164" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg class="bi-cart-delete" viewBox="0 0 154 164" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M44.5 123C4.99995 119.5 -11.8431 56.4293 24 19.5C40.5 2.50001 72.5 -5.5 101.5 27.5L115.5 14.5" stroke="#D10000" stroke-width="8" stroke-linecap="round" /> <path d="M44.5 123C4.99995 119.5 -11.8431 56.4293 24 19.5C40.5 2.50001 72.5 -5.5 101.5 27.5L115.5 14.5" stroke="#D10000" stroke-width="8" stroke-linecap="round" />
<path d="M65.2123 159.963L56 60.0001C88.0236 76.3307 119.521 77.4194 149 60.0001C141.63 142.346 140.08 160.953 140.226 159.963H65.2123Z" stroke="#D10000" stroke-width="8" /> <path d="M65.2123 159.963L56 60.0001C88.0236 76.3307 119.521 77.4194 149 60.0001C141.63 142.346 140.08 160.953 140.226 159.963H65.2123Z" stroke="#D10000" stroke-width="8" />
<path d="M121 36L101.582 55L75 31" stroke="#D10000" stroke-width="8" stroke-linecap="round" /> <path d="M121 36L101.582 55L75 31" stroke="#D10000" stroke-width="8" stroke-linecap="round" />
</svg> </svg>
</a>
</td> </td>
</tr> </tr>
} }