Merge branch 'stage9_10' of https://git.is.ulstu.ru/ns.potapov/PIbd-21_CourseWork_Polyclinic_BeSick into stage9_10
This commit is contained in:
commit
be8a36c9eb
@ -55,6 +55,7 @@ namespace PolyclinicWebAppImplementer.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult Edit(int id, DiagnoseViewModel model)
|
public IActionResult Edit(int id, DiagnoseViewModel model)
|
||||||
{
|
{
|
||||||
|
// TODO проверить, что пользователь хочет редактировать свой диагноз (UserId)
|
||||||
if (HttpContext.Request.Method == "GET")
|
if (HttpContext.Request.Method == "GET")
|
||||||
{
|
{
|
||||||
var obj = _diagnoseLogic.ReadElement(new DiagnoseSearchModel { Id = id });
|
var obj = _diagnoseLogic.ReadElement(new DiagnoseSearchModel { Id = id });
|
||||||
@ -79,6 +80,7 @@ namespace PolyclinicWebAppImplementer.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult Delete(int id)
|
public IActionResult Delete(int id)
|
||||||
{
|
{
|
||||||
|
// TODO проверить, что пользователь хочет удалить свой диагноз (UserId)
|
||||||
var obj = _diagnoseLogic.ReadElement(new DiagnoseSearchModel { Id = id });
|
var obj = _diagnoseLogic.ReadElement(new DiagnoseSearchModel { Id = id });
|
||||||
if (obj != null)
|
if (obj != null)
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,78 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using PolyclinicContracts.BindingModels;
|
||||||
|
using PolyclinicContracts.BusinessLogicsContracts;
|
||||||
|
using PolyclinicContracts.SearchModels;
|
||||||
|
using PolyclinicContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace PolyclinicWebAppImplementer.Controllers
|
||||||
|
{
|
||||||
|
public class SymptomesController : Controller
|
||||||
|
{
|
||||||
|
private readonly ISymptomLogic _symptomLogic;
|
||||||
|
private readonly IDiagnoseLogic _diagnoseLogic;
|
||||||
|
public SymptomesController(ISymptomLogic symptomLogic, IDiagnoseLogic diagnoseLogic)
|
||||||
|
{
|
||||||
|
_symptomLogic = symptomLogic;
|
||||||
|
_diagnoseLogic = diagnoseLogic;
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
List<SymptomViewModel> symptomes = _symptomLogic.ReadList();
|
||||||
|
ViewData["Title"] = "Список симптомов";
|
||||||
|
return View("SymptomesList", symptomes);
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult Add(SymptomViewModel model)
|
||||||
|
{
|
||||||
|
if (HttpContext.Request.Method == "GET")
|
||||||
|
{
|
||||||
|
ViewData["Title"] = "Новый симптом";
|
||||||
|
return View("SymptomForm");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SymptomBindingModel symptom = new SymptomBindingModel
|
||||||
|
{
|
||||||
|
Name = model.Name,
|
||||||
|
Comment = model.Comment,
|
||||||
|
};
|
||||||
|
_symptomLogic.Create(symptom);
|
||||||
|
return RedirectToAction("Index");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult Edit(int id, SymptomViewModel model)
|
||||||
|
{
|
||||||
|
if (HttpContext.Request.Method == "GET")
|
||||||
|
{
|
||||||
|
var obj = _symptomLogic.ReadElement(new SymptomSearchModel { Id = id });
|
||||||
|
ViewData["Title"] = "Редактировать симптом";
|
||||||
|
return View("SymptomForm", obj);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SymptomBindingModel symptom = new SymptomBindingModel
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
Comment = model.Comment,
|
||||||
|
};
|
||||||
|
_symptomLogic.Update(symptom);
|
||||||
|
return RedirectToAction("Index");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult Delete(int id)
|
||||||
|
{
|
||||||
|
var obj = _symptomLogic.ReadElement(new SymptomSearchModel { Id = id });
|
||||||
|
if (obj != null)
|
||||||
|
{
|
||||||
|
_symptomLogic.Delete(new SymptomBindingModel { Id = obj.Id });
|
||||||
|
}
|
||||||
|
return RedirectToAction("Index");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -22,7 +22,7 @@
|
|||||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Update="Views\Home\Symptomes.cshtml">
|
<Content Update="Views\Symptomes\SymptomesList.cshtml">
|
||||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
@{
|
@using PolyclinicContracts.ViewModels
|
||||||
ViewBag.SelectedSiteMenuItem = SiteMenuItems.Symptom;
|
@model SymptomViewModel
|
||||||
}
|
<h4>@ViewData["Title"]</h4>
|
||||||
<h4>Новый симптом</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" id="name" name="name" /></div>
|
<div class="col-8"><input type="text" asp-for="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 id="comment" name="comment"></textarea></div>
|
<div class="col-8"><textarea asp-for="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">
|
@ -3,7 +3,7 @@
|
|||||||
}
|
}
|
||||||
<div>
|
<div>
|
||||||
<div class="d-flex flex-row">
|
<div class="d-flex flex-row">
|
||||||
<a class="btn btn-primary" asp-action="Symptom" asp-controller="Home" title="Добавить">
|
<a class="btn btn-primary" asp-action="Add" title="Добавить">
|
||||||
Добавить симптом
|
Добавить симптом
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
Loading…
Reference in New Issue
Block a user