Работает добавление, редактирование и удаление диагнозов
This commit is contained in:
parent
9f44ad75be
commit
bdd5a9649a
@ -1,5 +1,6 @@
|
||||
using PolyclinicDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace PolyclinicContracts.ViewModels
|
||||
{
|
||||
|
@ -44,6 +44,8 @@ namespace PolyclinicDatabaseImplement.Models
|
||||
}
|
||||
Name = model.Name;
|
||||
Comment = model.Comment;
|
||||
DateStartDiagnose = model.DateStartDiagnose;
|
||||
DateStopDiagnose = model.DateStopDiagnose;
|
||||
}
|
||||
|
||||
public DiagnoseViewModel GetViewModel => new()
|
||||
|
@ -23,12 +23,13 @@ namespace PolyclinicWebAppImplementer.Controllers
|
||||
{
|
||||
// TODO выводить только пользовательские диагнозы
|
||||
List<DiagnoseViewModel> diagnoses = _diagnoseLogic.ReadList();
|
||||
ViewData["Title"] = "Список диагнозов";
|
||||
return View("DiagnosesList", diagnoses);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[HttpPost]
|
||||
public IActionResult Add(int id, string name, string comment, DateTime dateStart, DateTime dateStop)
|
||||
public IActionResult Add(int id, string name, string comment, DateTime dateStart, DateTime? dateStop)
|
||||
{
|
||||
if (HttpContext.Request.Method == "GET")
|
||||
{
|
||||
@ -53,7 +54,7 @@ namespace PolyclinicWebAppImplementer.Controllers
|
||||
|
||||
[HttpGet]
|
||||
[HttpPost]
|
||||
public IActionResult Edit(int id, string name, string comment, DateTime dateStart, DateTime dateStop)
|
||||
public IActionResult Edit(int id, string name, string comment, DateTime dateStart, DateTime? dateStop)
|
||||
{
|
||||
if (HttpContext.Request.Method == "GET")
|
||||
{
|
||||
@ -75,5 +76,16 @@ namespace PolyclinicWebAppImplementer.Controllers
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult Delete(int id)
|
||||
{
|
||||
var obj = _diagnoseLogic.ReadElement(new DiagnoseSearchModel { Id = id });
|
||||
if (obj != null)
|
||||
{
|
||||
_diagnoseLogic.Delete(new DiagnoseBindingModel { Id = obj.Id });
|
||||
}
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,22 +2,22 @@
|
||||
@model DiagnoseViewModel
|
||||
<h4>@ViewData["Title"]</h4>
|
||||
<form class="d-flex flex-column" method="post">
|
||||
<input type="hidden" name="id" readonly value="@Model?.Id" />
|
||||
<input type="hidden" name="id" readonly asp-for="Id" />
|
||||
<div class="row mb-5">
|
||||
<div class="col-3">Название:</div>
|
||||
<div class="col-8"><input type="text" id="name" name="name" value="@Model?.Name" /></div>
|
||||
<div class="col-8"><input required type="text" id="name" name="name" asp-for="Name" /></div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-3">Коментарий:</div>
|
||||
<div class="col-8"><textarea id="comment" name="comment">@Model?.Comment</textarea></div>
|
||||
<div class="col-8"><textarea id="comment" name="comment" asp-for="Comment"></textarea></div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-3">Начало:</div>
|
||||
<div class="col-8"><input type="date" id="dateStartInput" name="dateStart" value="@Model?.DateStartDiagnose" /></div>
|
||||
<div class="col-8"><input required type="date" id="dateStartInput" name="dateStart" asp-for="DateStartDiagnose" /></div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-3">Конец:</div>
|
||||
<div class="col-8"><input type="date" id="dateStopInput" name="dateStop" value="@Model?.DateStopDiagnose" /></div>
|
||||
<div class="col-8"><input type="date" id="dateStopInput" name="dateStop" asp-for="DateStopDiagnose" value="" placeholder=""/></div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">
|
||||
|
@ -26,16 +26,18 @@
|
||||
<tr>
|
||||
<th scope="row">@item.Id</th>
|
||||
<td>@item.Name</td>
|
||||
<td>@item.DateStartDiagnose</td>
|
||||
<td>@item.DateStopDiagnose</td>
|
||||
<td>@item.DateStartDiagnose.ToShortDateString()</td>
|
||||
<td>@item.DateStopDiagnose?.ToShortDateString()</td>
|
||||
<td>@item.Comment</td>
|
||||
<td class="d-flex">
|
||||
<a class="btn btn-danger me-1" title="Удалить">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash-fill" viewBox="0 0 16 16">
|
||||
<path d="M2.5 1a1 1 0 0 0-1 1v1a1 1 0 0 0 1 1H3v9a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V4h.5a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H10a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1zm3 4a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5M8 5a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7A.5.5 0 0 1 8 5m3 .5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 1 0" />
|
||||
</svg>
|
||||
</a>
|
||||
<a class="btn btn-warning text-light" title="Редактировать" asp-action="Edit" asp-controller="Diagnoses">
|
||||
<form method="post" asp-action="Delete" asp-route-id="@item.Id">
|
||||
<button class="btn btn-danger me-1" title="Удалить" type="submit">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash-fill" viewBox="0 0 16 16">
|
||||
<path d="M2.5 1a1 1 0 0 0-1 1v1a1 1 0 0 0 1 1H3v9a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V4h.5a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H10a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1zm3 4a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5M8 5a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7A.5.5 0 0 1 8 5m3 .5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 1 0" />
|
||||
</svg>
|
||||
</button>
|
||||
</form>
|
||||
<a class="btn btn-warning text-light" title="Редактировать" asp-action="Edit" asp-route-id="@item.Id">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil-fill" viewBox="0 0 16 16">
|
||||
<path d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.5.5 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11z" />
|
||||
</svg>
|
||||
|
Loading…
Reference in New Issue
Block a user