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

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 Microsoft.AspNetCore.Mvc;
using PolyclinicBusinessLogic.BusinessLogics;
using PolyclinicContracts.BindingModels;
using PolyclinicContracts.BusinessLogicsContracts; using PolyclinicContracts.BusinessLogicsContracts;
using PolyclinicContracts.SearchModels;
using PolyclinicContracts.ViewModels; using PolyclinicContracts.ViewModels;
using PolyclinicWebAppSuretor.Models; using PolyclinicWebAppSuretor.Models;
using System.Diagnostics; using System.Diagnostics;
@ -52,10 +55,53 @@ namespace PolyclinicWebAppSuretor.Controllers
return View(); return View();
} }
public IActionResult CreateProcedure() [HttpGet]
[HttpPost]
public IActionResult CreateProcedure(string name, string? comment, DateTime dateStart, DateTime? dateStop)
{ {
if (HttpContext.Request.Method == "GET")
{
ViewData["Title"] = "Íîâàÿ ïðîöåäóðà";
return View(); 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() public IActionResult CreateMedicament()
{ {

View File

@ -1,5 +1,5 @@
@using PolyclinicContracts.ViewModels @using PolyclinicContracts.ViewModels
@model List<ProcedureViewModel> @model ProcedureViewModel
@{ @{
ViewData["Title"] = "CreateProcedure"; ViewData["Title"] = "CreateProcedure";
} }
@ -10,40 +10,38 @@
<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" />
<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 class="col-6" type="text" style="width: 45vh" /> <input required type="text" id="name" name="name" 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 class="col-6" id="comment" name="comment" style="width: 45vh"> <textarea type="text" id="comment" name="comment" asp-for="Comment" style="width: 45vh">
</textarea> </textarea>
</div> </div>
</div> </div>
<div class="d-flex flex-column mb-5 mt-5 justify-content-between align-content-around"> <div class="d-flex flex-column mb-5 mt-5 justify-content-between align-content-around">
<div class="mb-5 me-3"> <div class="mb-5 me-3">
<label for="dateFrom" class="me-3"> <label for="dateStart" class="me-3">
Дата начала Дата начала
</label> </label>
<input type="date" id="dateFrom" name="dateFrom" /> <input type="date" id="dateStart" name="dateStart" asp-for="DateStartProcedure" />
</div> </div>
<div class="mb-5 me-3"> <div class="mb-5 me-3">
<label for="dateTo" class="me-3"> <label for="dateStop" class="me-3">
Дата завершения Дата завершения
</label> </label>
<input type="date" id="dateTo" name="dateTo" /> <input type="date" id="dateStop" name="dateStop" asp-for="DateStopProcedure" />
</div> </div>
<div class="col-4"> <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>
</div> </div>
</form> </form>

View File

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