This commit is contained in:
Елена Бакальская 2024-05-28 11:23:35 +04:00
commit f6c52a08ad
5 changed files with 49 additions and 37 deletions

View File

@ -3,6 +3,7 @@ using PolyclinicContracts.BindingModels;
using PolyclinicContracts.BusinessLogicsContracts; using PolyclinicContracts.BusinessLogicsContracts;
using PolyclinicContracts.SearchModels; using PolyclinicContracts.SearchModels;
using PolyclinicContracts.ViewModels; using PolyclinicContracts.ViewModels;
using PolyclinicWebAppImplementer.Models;
namespace PolyclinicWebAppImplementer.Controllers namespace PolyclinicWebAppImplementer.Controllers
{ {
@ -24,19 +25,21 @@ namespace PolyclinicWebAppImplementer.Controllers
} }
[HttpGet] [HttpGet]
[HttpPost] [HttpPost]
public IActionResult Add(SymptomViewModel model) public IActionResult Add(SymptomFormModel model)
{ {
if (HttpContext.Request.Method == "GET") if (HttpContext.Request.Method == "GET")
{ {
ViewData["Title"] = "Новый симптом"; ViewData["Title"] = "Новый симптом";
return View("SymptomForm"); model = new();
model.AvailableDiagnoses = _diagnoseLogic.ReadList();
return View("SymptomForm", model);
} }
else else
{ {
SymptomBindingModel symptom = new SymptomBindingModel SymptomBindingModel symptom = new SymptomBindingModel
{ {
Name = model.Name, Name = model.SymptomViewModel.Name,
Comment = model.Comment, Comment = model.SymptomViewModel.Comment,
}; };
_symptomLogic.Create(symptom); _symptomLogic.Create(symptom);
return RedirectToAction("Index"); return RedirectToAction("Index");

View File

@ -0,0 +1,11 @@
using PolyclinicContracts.ViewModels;
namespace PolyclinicWebAppImplementer.Models
{
public class SymptomFormModel
{
public SymptomViewModel? SymptomViewModel { get; set; }
public List<DiagnoseViewModel> SelectecDiagnoses { get; set; } = new();
public List<DiagnoseViewModel> AvailableDiagnoses { get; set; } = new();
}
}

View File

@ -5,7 +5,7 @@
public static (string Controller, string Action, string Title) Index = ("Home", "", "Главная"); public static (string Controller, string Action, string Title) Index = ("Home", "", "Главная");
public static (string Controller, string Action, string Title) Courses = ("Home", "Courses", "Курсы"); public static (string Controller, string Action, string Title) Courses = ("Home", "Courses", "Курсы");
public static (string Controller, string Action, string Title) Diagnoses = ("Diagnoses", "", "Болезни"); public static (string Controller, string Action, string Title) Diagnoses = ("Diagnoses", "", "Болезни");
public static (string Controller, string Action, string Title) Symptomes = ("Home", "Symptomes", "Симптомы"); public static (string Controller, string Action, string Title) Symptomes = ("Symptomes", "", "Симптомы");
public static (string Controller, string Action, string Title) Symptom = ("Home", "Symptom", "Симптом"); public static (string Controller, string Action, string Title) Symptom = ("Home", "Symptom", "Симптом");
public static (string Controller, string Action, string Title) Diagnose = ("Home", "Diagnose", "Болезнь"); public static (string Controller, string Action, string Title) Diagnose = ("Home", "Diagnose", "Болезнь");
public static (string Controller, string Action, string Title) Course = ("Home", "Course", "Курс"); public static (string Controller, string Action, string Title) Course = ("Home", "Course", "Курс");

View File

@ -1,26 +1,23 @@
@using PolyclinicContracts.ViewModels @model SymptomFormModel
@model SymptomViewModel
<h4>@ViewData["Title"]</h4> <h4>@ViewData["Title"]</h4>
<form class="d-flex flex-column" method="post"> <form class="d-flex flex-column" method="post">
<div class="row mb-5"> <div class="row mb-5">
<div class="col-3">Название:</div> <div class="col-3">Название:</div>
<div class="col-8"><input type="text" asp-for="Name" /></div> <div class="col-8"><input type="text" asp-for="SymptomViewModel.Name" /></div>
</div> </div>
<div class="row mb-5"> <div class="row mb-5">
<div class="col-3">Коментарий:</div> <div class="col-3">Коментарий:</div>
<div class="col-8"><textarea asp-for="Comment"></textarea></div> <div class="col-8"><textarea asp-for="SymptomViewModel.Comment"></textarea></div>
</div> </div>
<div class="row mb-5"> <div class="row mb-5">
<div class="col-3 d-flex align-content-center"> <div class="col-3 d-flex align-content-center">
<h5 class="me-2">Болезни</h5> <h5 class="me-2">Болезни</h5>
<select id="diagnoseId" name="diagnoseId" class="me-2"> <select id="diagnoseId" name="diagnoseId" class="me-2">
<option value="">Выберите болезнь</option> <option value="">Выберите болезнь</option>
@{ @foreach (var availableDiagnose in Model.AvailableDiagnoses)
int count = 10; {
for (int i = 0; i < count; i++) <option value="@availableDiagnose.Id">@availableDiagnose.Name</option>
{
<option value="@i">Какая-то противная болезнь @i</option>
}
} }
</select> </select>
<button class="btn btn-success" type="button"> <button class="btn btn-success" type="button">
@ -31,7 +28,7 @@
<div class="row mb-5 overflow-auto" style="max-height: 100px; max-width: 500px;"> <div class="row mb-5 overflow-auto" style="max-height: 100px; max-width: 500px;">
<ol> <ol>
@{ @{
count = 7; int count = 7;
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
<li class="mb-2 ps-1 ms-1"> <li class="mb-2 ps-1 ms-1">
@ -51,7 +48,7 @@
<button class="btn btn-success" type="submit"> <button class="btn btn-success" type="submit">
Сохранить Сохранить
</button> </button>
@Html.ActionLink("Отмена", "Courses", "Home", null, new { @class = "btn btn-danger" }) @Html.ActionLink("Отмена", "", "Symptomes", null, new { @class = "btn btn-danger" })
</div> </div>
</div> </div>
</form> </form>

View File

@ -1,4 +1,6 @@
@{ @using PolyclinicContracts.ViewModels
@model List<SymptomViewModel>
@{
ViewBag.SelectedSiteMenuItem = SiteMenuItems.Symptomes; ViewBag.SelectedSiteMenuItem = SiteMenuItems.Symptomes;
} }
<div> <div>
@ -17,28 +19,27 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@{ @foreach (var item in Model)
int count = 10; {
for (int i = 0; i < count; i++) <tr>
{ <th scope="row">@item.Id</th>
<tr> <td>@item.Name</td>
<th scope="row">@i</th> <td>@item.Comment</td>
<td>вранье</td> <td class="d-flex">
<td>пациент постоянно врёт о своих приключениях</td> <form method="post" asp-action="Delete" asp-route-id="@item.Id">
<td class="d-flex"> <button class="btn btn-danger me-1" title="Удалить" type="submit">
<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"> <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" /> <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> </svg>
</a> </button>
<a class="btn btn-warning text-light" title="Редактировать" asp-action="Symptom" asp-controller="Home"> </form>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil-fill" viewBox="0 0 16 16"> <a class="btn btn-warning text-light" title="Редактировать" asp-action="Edit" asp-route-id="@item.Id">
<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 xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil-fill" viewBox="0 0 16 16">
</svg> <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" />
</a> </svg>
</td> </a>
</tr> </td>
} </tr>
} }
</tbody> </tbody>
</table> </table>