This commit is contained in:
Никита Потапов 2024-05-28 00:27:22 +04:00
commit 34cae3a0ed
8 changed files with 247 additions and 113 deletions

View File

@ -8,6 +8,6 @@ namespace PolyclinicContracts.BindingModels
public int? CourseId { get; set; }
public int ProceduresCount { get; set; }
public string Comment { get; set; } = string.Empty;
public Dictionary<int, IProcedureModel> RecipeProcedures { get; } = new();
public Dictionary<int, IProcedureModel> RecipeProcedures { get; set; } = new();
}
}

View File

@ -13,11 +13,21 @@ namespace PolyclinicWebAppSuretor.Controllers
{
private readonly ILogger<HomeController> _logger;
private readonly IProcedureLogic _procedureLogic;
private readonly IMedicamentLogic _medicamentLogic;
private readonly IRecipeLogic _recipeLogic;
private readonly ISymptomLogic _symptomLogic;
public HomeController(ILogger<HomeController> logger, IProcedureLogic procedureLogic)
public HomeController(ILogger<HomeController> logger,
IProcedureLogic procedureLogic,
IMedicamentLogic medicamentLogic,
IRecipeLogic recipeLogic,
ISymptomLogic symptomLogic)
{
_logger = logger;
_procedureLogic = procedureLogic;
_medicamentLogic = medicamentLogic;
_recipeLogic = recipeLogic;
_symptomLogic = symptomLogic;
}
public IActionResult Index()
@ -30,10 +40,150 @@ namespace PolyclinicWebAppSuretor.Controllers
return View();
}
public IActionResult Medicaments()
public IActionResult Recipes()
{
List<RecipeViewModel> recipes = _recipeLogic.ReadList(null);
if (recipes == null)
{
recipes = new();
}
return View(recipes);
}
[HttpGet]
[HttpPost]
public IActionResult CreateRecipe(RecipeViewModel model)
{
ViewBag.Procedures = _procedureLogic.ReadList(null);
ViewBag.RecipeProcedures = _recipeLogic.
if (HttpContext.Request.Method == "GET")
{
ViewData["Title"] = "Íîâûé ðåöåïò";
return View();
}
else
{
// TODO ïðîïèñàòü UserId
RecipeBindingModel recipe = new RecipeBindingModel
{
Comment = model.Comment,
CourseId = model.CourseId,
ProceduresCount = model.ProceduresCount,
RecipeProcedures = model.RecipeProcedures
};
_recipeLogic.Create(recipe);
return RedirectToAction("Medicaments");
}
}
[HttpGet]
[HttpPost]
public IActionResult EditRecipe(MedicamentViewModel model)
{
if (HttpContext.Request.Method == "GET")
{
var obj = _medicamentLogic.ReadElement(new MedicamentSearchModel { Id = model.Id });
ViewData["Title"] = "Ðåäàêòèðîâàòü ïðåïàðàò";
return View("CreateMedicament", obj);
}
else
{
MedicamentBindingModel medicament = new MedicamentBindingModel
{
Id = model.Id,
Name = model.Name,
Comment = model.Comment ?? string.Empty,
SymptomId = model.SymptomId,
ProcedureId = model.ProcedureId,
};
_medicamentLogic.Update(medicament);
return RedirectToAction("Medicaments");
}
}
[HttpPost]
public IActionResult DeleteRecipe(int id)
{
var obj = _medicamentLogic.ReadElement(new MedicamentSearchModel { Id = id });
if (obj != null)
{
_medicamentLogic.Delete(new MedicamentBindingModel { Id = obj.Id });
}
return RedirectToAction("Medicaments");
}
public IActionResult Medicaments()
{
List<MedicamentViewModel> medicaments = _medicamentLogic.ReadList(null);
if (medicaments == null)
{
medicaments = new();
}
return View(medicaments);
}
[HttpGet]
[HttpPost]
public IActionResult CreateMedicament(MedicamentViewModel model)
{
ViewBag.Procedures = _procedureLogic.ReadList(null);
ViewBag.Symptomes = _symptomLogic.ReadList(null);
if (HttpContext.Request.Method == "GET")
{
ViewData["Title"] = "Íîâûé ïðåïàðàò";
return View();
}
else
{
// TODO ïðîïèñàòü UserId
MedicamentBindingModel medicament = new MedicamentBindingModel
{
Name = model.Name,
Comment = model.Comment ?? string.Empty,
SymptomId = model.SymptomId,
ProcedureId = model.ProcedureId,
};
_medicamentLogic.Create(medicament);
return RedirectToAction("Medicaments");
}
}
[HttpGet]
[HttpPost]
public IActionResult EditMedicament(MedicamentViewModel model)
{
if (HttpContext.Request.Method == "GET")
{
var obj = _medicamentLogic.ReadElement(new MedicamentSearchModel { Id = model.Id });
ViewData["Title"] = "Ðåäàêòèðîâàòü ïðåïàðàò";
return View("CreateMedicament", obj);
}
else
{
MedicamentBindingModel medicament = new MedicamentBindingModel
{
Id = model.Id,
Name = model.Name,
Comment = model.Comment ?? string.Empty,
SymptomId = model.SymptomId,
ProcedureId = model.ProcedureId,
};
_medicamentLogic.Update(medicament);
return RedirectToAction("Medicaments");
}
}
[HttpPost]
public IActionResult DeleteMedicament(int id)
{
var obj = _medicamentLogic.ReadElement(new MedicamentSearchModel { Id = id });
if (obj != null)
{
_medicamentLogic.Delete(new MedicamentBindingModel { Id = obj.Id });
}
return RedirectToAction("Medicaments");
}
public IActionResult Procedures()
{
@ -45,16 +195,6 @@ namespace PolyclinicWebAppSuretor.Controllers
return View(procedure);
}
public IActionResult Recipes()
{
return View();
}
public IActionResult CreateRecipe()
{
return View();
}
[HttpGet]
[HttpPost]
public IActionResult CreateProcedure(ProcedureViewModel model)
@ -115,11 +255,6 @@ namespace PolyclinicWebAppSuretor.Controllers
return RedirectToAction("Procedures");
}
public IActionResult CreateMedicament()
{
return View();
}
public IActionResult ListCoursesByProcedures()
{
return View();

View File

@ -17,6 +17,15 @@ builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>();
builder.Services.AddTransient<IMedicamentStorage, MedicamentStorage>();
builder.Services.AddTransient<IRecipeStorage, RecipeStorage>();
builder.Services.AddTransient<IDiagnoseLogic, DiagnoseLogic>();
builder.Services.AddTransient<ICourseLogic, CourseLogic>();
builder.Services.AddTransient<ISymptomLogic, SymptomLogic>();
builder.Services.AddTransient<IDiagnoseStorage, DiagnoseStorage>();
builder.Services.AddTransient<ICourseStorage, CourseStorage>();
builder.Services.AddTransient<ISymptomStorage, SymptomStorage>();
var app = builder.Build();
// Configure the HTTP request pipeline.

View File

@ -1,10 +1,9 @@
@using PolyclinicContracts.ViewModels
@model List<MedicamentViewModel>
@{
ViewData["Title"] = "CreateMedicament";
}
@model MedicamentViewModel
<div class="text-center mt-3 mb-3">
<h2 class="display-4">Создание препарата</h2>
<h3>@ViewData["Title"]</h3>
</div>
<form method="post" class="form-create-medicament d-flex flex-row justify-content-around align-items-center">
@ -15,14 +14,14 @@
<h3 class="col-3">
Название:
</h3>
<input class="col-6" type="text" style="width: 45vh" />
<input class="col-6" type="text" style="width: 45vh" asp-for="Name" />
</div>
<div class="d-flex flex-row mb-5 flex-row justify-content-between align-items-center">
<h3 class="col-3">
Комментарий:
</h3>
<textarea class="col-6" id="comment" name="comment" style="width: 45vh">
<textarea class="col-6" id="comment" name="comment" style="width: 45vh" asp-for="Comment">
</textarea>
@ -32,14 +31,12 @@
<h3 class="col-3">
Выбор процедуры:
</h3>
<select id="procedureId" name="procedureId" style="width: 45vh">
@* <option value="">Выберите процедуру</option> *@
@{
int count = 3;
for (int i = 1; i <= count; i++)
<select id="procedureId" name="procedureId" style="width: 45vh" asp-for="ProcedureId">
<option value="">Выберите процедуру</option>
@foreach (var procedure in ViewBag.Procedures)
{
<option value="@i">процедура "@i"</option>
}
<option value="@procedure.Id">@procedure.Name</option>
}
</select>
@ -50,13 +47,11 @@
<h3 class="col-3">
Выбор симптома:
</h3>
<select id="symptomId" name="symptomId" style="width: 45vh">
@* <option value="">Выберите симптом</option> *@
@{
for (int i = 1; i <= count; i++)
<select id="symptomId" name="symptomId" style="width: 45vh" asp-for="SymptomId">
<option value="">Выберите симптом</option>
@foreach (var symptom in ViewBag.Symptomes)
{
<option value="@i">симптом "@i"</option>
}
<option value="@symptom.Id">@symptom.Name</option>
}
</select>
</div>
@ -64,7 +59,7 @@
<div class="d-flex flex-column mb-5 mt-5">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Сохранить" class="button-save-medicament btn" asp-action="Medicaments" />
<input type="submit" value="Сохранить" class="button-save-medicament btn"/>
</div>
</div>
</form>

View File

@ -1,10 +1,10 @@
@using PolyclinicContracts.ViewModels
@model List<RecipeViewModel>
@model RecipeViewModel
@{
ViewData["Title"] = "CreateRecipe";
}
<div class="text-center mt-3 mb-3">
<h2 class="display-4">Создание рецепта</h2>
<h2 class="display-4">@ViewData["Title"]</h2>
</div>
<form method="post" class="form-create-recipe d-flex flex-row justify-content-around align-items-center">
@ -15,14 +15,14 @@
<h3 class="col-3">
Количество процедур:
</h3>
<input class="col-6" type="text" style="width: 45vh" />
<input class="col-6" type="text" style="width: 45vh" asp-for="ProceduresCount" />
</div>
<div class="d-flex flex-row mb-5 flex-row justify-content-between align-items-center">
<h3 class="col-3">
Комментарий:
</h3>
<textarea class="col-6" id="comment" name="comment" style="width: 45vh">
<textarea class="col-6" id="comment" name="comment" style="width: 45vh" asp-for="Comment">
</textarea>
@ -32,14 +32,11 @@
<h3 class="col-3">
Выбор процедуры:
</h3>
<select id="procedureId" name="procedureId" style="width: 45vh">
@* <option value="">Выберите процедуру/ы</option> *@
@{
int count = 3;
for (int i = 1; i <= count; i++)
<select id="procedureId" name="procedureId" style="width: 45vh" multiple>
<option value="">Выберите процедуру/ы</option>
@foreach (var item in ViewBag.Procedures)
{
<option value="@i">процедура "@i"</option>
}
<option value="@item.Id">@item.Name</option>
}
</select>
</div>
@ -55,12 +52,10 @@
</tr>
</thead>
<tbody>
@{
int cRows = 20;
for (int i = 1; i <= cRows; i++)
@foreach (var item in ViewBag.RecipeProcedures)
{
<tr>
<td>Процедура № @i </td>
<td>Процедура № @item.Id @item.Name</td>
<td>
<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" />
@ -69,7 +64,7 @@
</svg>
</td>
</tr>
}
}
</tbody>
</table>

View File

@ -1,8 +1,6 @@
@using PolyclinicContracts.ViewModels
@model List<MedicamentViewModel>
@{
ViewData["Title"] = "Medicaments";
}
@ViewData["Title"] = "Medicaments";
<div class="text-center">
<h1 class="display-4">Препараты</h1>
@ -31,7 +29,7 @@
Симптом
</th>
<th>
Рецепт (номер)
Процедура
</th>
<th>
Комментарий
@ -49,26 +47,28 @@
{
<td>@item.Id</td>
<td>@item.Name</td>
<td>@item.SymptomId.</td>
<td>@item.SymptomName</td>
<td>@item.ProcedureName</td>
<td>@item.Comment</td>
<td>
3
</td>
<td>
При особом неврозе употребляйте каждый день и спина не будет болеть
</td>
<td>
<a asp-action="CreateMedicament">
<a asp-action="EditMedicament" asp-route-id="@item.Id">
<svg class="bi-edit-pen" viewBox="0 0 127 127" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M105.5 26L37 114.5C34.5 117 16.3 121.7 7.5 122.5C79.1 34.1 101 5.5 102 4C104.833 4.5 119.3 14.6 122.5 21C105 44 98.5 55 111.5 58.5" stroke="#008315" stroke-width="6" stroke-linecap="round" />
</svg>
</a>
</td>
<td>
<form method="post" asp-action="DeleteMedicament" asp-route-id="@item.Id">
<button class="btn" 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>
</button>
</form>
</td>
}
</tbody>

View File

@ -49,7 +49,7 @@
</td>
<td>
<form method="post" asp-action="DeleteProcedure" asp-route-id="@item.Id">
<button type="submit">
<button class="btn" 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" />

View File

@ -1,8 +1,5 @@
@using PolyclinicContracts.ViewModels
@model List<RecipeViewModel>
@{
ViewData["Title"] = "Recipes";
}
<div class="text-center">
<h1 class="display-4">Рецепты</h1>
</div>
@ -42,29 +39,32 @@
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<td>@item.Id</td>
<td>@item.Comment</td>
<td>@item.ProceduresCount</td>
<td>
1
</td>
<td>
Это процедура для вашей спины
</td>
<td>
4
</td>
<td>
<a asp-action="CreateRecipe">
<a asp-action="CreateRecipe" asp-route-id="@item.Id">
<svg class="bi-edit-pen" viewBox="0 0 127 127" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M105.5 26L37 114.5C34.5 117 16.3 121.7 7.5 122.5C79.1 34.1 101 5.5 102 4C104.833 4.5 119.3 14.6 122.5 21C105 44 98.5 55 111.5 58.5" stroke="#008315" stroke-width="6" stroke-linecap="round" />
</svg>
</a>
</td>
<td>
<form method="post" asp-route-id="@item.Id">
<button class="btn" 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>
</button>
</form>
</td>
}
</tbody>
</table>
}