ну... процедура создается, но пока не меняется (не апдейтится)

This commit is contained in:
Елена Бакальская 2024-05-26 18:16:46 +04:00
parent c26bbd5d6a
commit 21b9bed09b
3 changed files with 94 additions and 68 deletions

View File

@ -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()

View File

@ -1,5 +1,5 @@
@using PolyclinicContracts.ViewModels
@model List<ProcedureViewModel>
@model ProcedureViewModel
@{
ViewData["Title"] = "CreateProcedure";
}
@ -10,40 +10,38 @@
<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">
<input type="hidden" name="id" readonly asp-for="Id" />
<div class="d-flex flex-row mb-5 flex-row justify-content-between align-items-center">
<h3 class="col-3 m-3">
Название:
</h3>
<input class="col-6" type="text" style="width: 45vh" />
<input required type="text" id="name" name="name" asp-for="Name" />
</div>
<div class="d-flex flex-row mb-5 flex-row justify-content-between align-items-center">
<h3 class="col-3 m-3">
Комментарий:
</h3>
<textarea class="col-6" id="comment" name="comment" style="width: 45vh">
<textarea type="text" id="comment" name="comment" asp-for="Comment" style="width: 45vh">
</textarea>
</div>
</div>
<div class="d-flex flex-column mb-5 mt-5 justify-content-between align-content-around">
<div class="mb-5 me-3">
<label for="dateFrom" class="me-3">
<label for="dateStart" class="me-3">
Дата начала
</label>
<input type="date" id="dateFrom" name="dateFrom" />
<input type="date" id="dateStart" name="dateStart" asp-for="DateStartProcedure" />
</div>
<div class="mb-5 me-3">
<label for="dateTo" class="me-3">
<label for="dateStop" class="me-3">
Дата завершения
</label>
<input type="date" id="dateTo" name="dateTo" />
<input type="date" id="dateStop" name="dateStop" asp-for="DateStopProcedure" />
</div>
<div class="col-4">
<input type="submit" value="Сохранить" class="button-save-procedure btn" asp-action="Procedures" />
<input type="submit" value="Сохранить" class="button-save-procedure btn" />
</div>
</div>
</form>

View File

@ -7,76 +7,58 @@
<h1 class="display-4">Процедуры</h1>
</div>
<div class="text-center">
<div>
@{
// if (Model == null)
// {
// <h3 class="display-4">Авторизируйтесь</h3>
// return;
// }
<p>
<a asp-action="CreateProcedure">Создать процедуру</a>
</p>
<div class="text-center">
<p>
<a asp-action="CreateProcedure">Создать процедуру</a>
</p>
</div>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Название процедуры
</th>
<th>
Дата начала процедуры
</th>
<th>
Дата окончания процедуры
</th>
<th>
Комментарий
</th>
<th>
Редактировать
</th>
<th>
Удалить
</th>
<th scope="col">Номер</th>
<th scope="col">Название процедуры</th>
<th scope="col">Дата начала процедуры</th>
<th scope="col">Дата окончания процедуры</th>
<th scope="col">Комментарий</th>
<th scope="col">Редактировать</th>
<th scope="col">Удалить</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
@foreach (var item in Model)
{
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateStartProcedure)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateStopProcedure)
</td>
<td>
@Html.DisplayFor(modelItem => item.Comment)
</td>
<td>
<a asp-action="CreateProcedure">
<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" />
</svg>
</a>
</td>
<td>
<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="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" />
</svg>
</td>
<tr>
<td scope="row">@Html.DisplayFor(modelItem => item.Id)</td>
<td>@Html.DisplayFor(modelItem => item.Name)</td>
<td>@Html.DisplayFor(modelItem => item.DateStartProcedure)</td>
<td>@Html.DisplayFor(modelItem => item.DateStopProcedure)</td>
<td>@Html.DisplayFor(modelItem => item.Comment)</td>
<td>
<a asp-action="CreateProcedure">
<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" />
</svg>
</a>
</td>
<td>
<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="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" />
</svg>
</td>
</tr>
}
</tbody>
</table>
}