доделала круды для процедур

This commit is contained in:
Елена Бакальская 2024-05-27 21:27:51 +04:00
parent c5b0f0fe6c
commit 4f6a0ba0be
2 changed files with 27 additions and 13 deletions

View File

@ -57,7 +57,7 @@ namespace PolyclinicWebAppSuretor.Controllers
[HttpGet]
[HttpPost]
public IActionResult CreateProcedure(string name, string? comment, DateTime dateStart, DateTime? dateStop)
public IActionResult CreateProcedure(ProcedureViewModel model)
{
if (HttpContext.Request.Method == "GET")
{
@ -69,10 +69,10 @@ namespace PolyclinicWebAppSuretor.Controllers
// TODO ïðîïèñàòü UserId
ProcedureBindingModel procedure = new ProcedureBindingModel
{
Name = name,
Comment = comment ?? string.Empty,
DateStartProcedure = dateStart,
DateStopProcedure = dateStop
Name = model.Name,
Comment = model.Comment ?? string.Empty,
DateStartProcedure = model.DateStartProcedure,
DateStopProcedure = model.DateStopProcedure
};
_procedureLogic.Create(procedure);
return RedirectToAction("Procedures");
@ -104,6 +104,17 @@ namespace PolyclinicWebAppSuretor.Controllers
}
}
[HttpPost]
public IActionResult DeleteProcedure(int id)
{
var obj = _procedureLogic.ReadElement(new ProcedureSearchModel { Id = id });
if (obj != null)
{
_procedureLogic.Delete(new ProcedureBindingModel { Id = obj.Id });
}
return RedirectToAction("Procedures");
}
public IActionResult CreateMedicament()
{
return View();

View File

@ -37,7 +37,7 @@
@foreach (var item in Model)
{
<tr>
<td scope="row">@Html.DisplayFor(modelItem => item.Id)</td>
<td scope="row">@item.Id</td>
<td>@item.Name</td>
<td>@item.DateStartProcedure.ToShortDateString()</td>
<td>@item.DateStopProcedure?.ToShortDateString()</td>
@ -50,13 +50,16 @@
</a>
</td>
<td>
<a asp-action="DeleteProcedure">
<form method="post" asp-action="DeleteProcedure" asp-route-id="@item.Id">
<button type="submit">
<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>
</a>
</button>
</form>
</td>
</tr>