доделала круды вроде для обычных сущностей, нужно привязки сделать..
This commit is contained in:
parent
abc0bcf254
commit
9c97590f23
@ -96,10 +96,6 @@ namespace PolyclinicBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException("Количество процедур не может быть равно нулю или быть меньше нуля", nameof(model));
|
throw new ArgumentNullException("Количество процедур не может быть равно нулю или быть меньше нуля", nameof(model));
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.Comment))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет комментария", nameof(model.Comment));
|
|
||||||
}
|
|
||||||
logger.LogInformation("Recipe. Comment:{Comment}. Id: { Id}", model.Comment, model.Id);
|
logger.LogInformation("Recipe. Comment:{Comment}. Id: { Id}", model.Comment, model.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ namespace PolyclinicDatabaseImplement.Implements
|
|||||||
|
|
||||||
public RecipeViewModel? GetElement(RecipeSearchModel bindingModel)
|
public RecipeViewModel? GetElement(RecipeSearchModel bindingModel)
|
||||||
{
|
{
|
||||||
if (!bindingModel.Id.HasValue || string.IsNullOrEmpty(bindingModel.Comment))
|
if (!bindingModel.Id.HasValue)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ namespace PolyclinicDatabaseImplement.Models
|
|||||||
CourseId = bindingModel.CourseId,
|
CourseId = bindingModel.CourseId,
|
||||||
Procedures = bindingModel.RecipeProcedures.Select(x => new RecipeProcedure
|
Procedures = bindingModel.RecipeProcedures.Select(x => new RecipeProcedure
|
||||||
{
|
{
|
||||||
Recipe = database.Recipes.First(y => y.Id == x.Key)
|
Procedure = database.Procedures.First(y => y.Id == x.Key),
|
||||||
}).ToList()
|
}).ToList()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ namespace PolyclinicDatabaseImplement.Models
|
|||||||
if (RecipeProcedures != null)
|
if (RecipeProcedures != null)
|
||||||
{
|
{
|
||||||
// удалили те, которых нет в модели
|
// удалили те, которых нет в модели
|
||||||
database.RecipeProcedures.RemoveRange(RecipeProcedures.Where(rec => !bindingModel.RecipeProcedures.ContainsKey(rec.RecipeId)));
|
database.RecipeProcedures.RemoveRange(RecipeProcedures);
|
||||||
database.SaveChanges();
|
database.SaveChanges();
|
||||||
}
|
}
|
||||||
var Procedure = database.Procedures.First(x => x.Id == bindingModel.Id);
|
var Procedure = database.Procedures.First(x => x.Id == bindingModel.Id);
|
||||||
|
@ -4,6 +4,7 @@ using PolyclinicContracts.BindingModels;
|
|||||||
using PolyclinicContracts.BusinessLogicsContracts;
|
using PolyclinicContracts.BusinessLogicsContracts;
|
||||||
using PolyclinicContracts.SearchModels;
|
using PolyclinicContracts.SearchModels;
|
||||||
using PolyclinicContracts.ViewModels;
|
using PolyclinicContracts.ViewModels;
|
||||||
|
using PolyclinicDataModels.Models;
|
||||||
using PolyclinicWebAppSuretor.Models;
|
using PolyclinicWebAppSuretor.Models;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
@ -16,18 +17,21 @@ namespace PolyclinicWebAppSuretor.Controllers
|
|||||||
private readonly IMedicamentLogic _medicamentLogic;
|
private readonly IMedicamentLogic _medicamentLogic;
|
||||||
private readonly IRecipeLogic _recipeLogic;
|
private readonly IRecipeLogic _recipeLogic;
|
||||||
private readonly ISymptomLogic _symptomLogic;
|
private readonly ISymptomLogic _symptomLogic;
|
||||||
|
private readonly ICourseLogic _courseLogic;
|
||||||
|
|
||||||
public HomeController(ILogger<HomeController> logger,
|
public HomeController(ILogger<HomeController> logger,
|
||||||
IProcedureLogic procedureLogic,
|
IProcedureLogic procedureLogic,
|
||||||
IMedicamentLogic medicamentLogic,
|
IMedicamentLogic medicamentLogic,
|
||||||
IRecipeLogic recipeLogic,
|
IRecipeLogic recipeLogic,
|
||||||
ISymptomLogic symptomLogic)
|
ISymptomLogic symptomLogic,
|
||||||
|
ICourseLogic courseLogic)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_procedureLogic = procedureLogic;
|
_procedureLogic = procedureLogic;
|
||||||
_medicamentLogic = medicamentLogic;
|
_medicamentLogic = medicamentLogic;
|
||||||
_recipeLogic = recipeLogic;
|
_recipeLogic = recipeLogic;
|
||||||
_symptomLogic = symptomLogic;
|
_symptomLogic = symptomLogic;
|
||||||
|
_courseLogic = courseLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
@ -52,63 +56,79 @@ namespace PolyclinicWebAppSuretor.Controllers
|
|||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult CreateRecipe(RecipeViewModel model)
|
public IActionResult CreateRecipe(RecipeModel model, int[] selectedProcedures)
|
||||||
{
|
{
|
||||||
ViewBag.Procedures = _procedureLogic.ReadList(null);
|
ViewBag.Courses = _courseLogic.ReadList(null);
|
||||||
if (HttpContext.Request.Method == "GET")
|
if (HttpContext.Request.Method == "GET")
|
||||||
{
|
{
|
||||||
ViewData["Title"] = "Íîâûé ðåöåïò";
|
ViewData["Title"] = "Íîâûé ðåöåïò";
|
||||||
return View();
|
model = new()
|
||||||
|
{
|
||||||
|
Procedures = _procedureLogic.ReadList(null).Select(x => (x, false)).ToList()
|
||||||
|
};
|
||||||
|
return View("CreateRecipe", model);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO ïðîïèñàòü UserId
|
var allProcedures = _procedureLogic.ReadList(null);
|
||||||
|
|
||||||
RecipeBindingModel recipe = new RecipeBindingModel
|
RecipeBindingModel recipe = new RecipeBindingModel
|
||||||
{
|
{
|
||||||
Comment = model.Comment,
|
ProceduresCount = model.RecipeViewModel.ProceduresCount,
|
||||||
CourseId = model.CourseId,
|
Comment = model.RecipeViewModel.Comment,
|
||||||
ProceduresCount = model.ProceduresCount,
|
RecipeProcedures = selectedProcedures
|
||||||
RecipeProcedures = model.RecipeProcedures
|
.ToDictionary(
|
||||||
|
x => x,
|
||||||
|
x => allProcedures.Where(y => y.Id == x) as IProcedureModel
|
||||||
|
)
|
||||||
};
|
};
|
||||||
_recipeLogic.Create(recipe);
|
_recipeLogic.Create(recipe);
|
||||||
return RedirectToAction("Medicaments");
|
return RedirectToAction("Recipes");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult EditRecipe(MedicamentViewModel model)
|
public IActionResult EditRecipe(int id, RecipeModel model, int[] selectedProcedures)
|
||||||
{
|
{
|
||||||
if (HttpContext.Request.Method == "GET")
|
if (HttpContext.Request.Method == "GET")
|
||||||
{
|
{
|
||||||
var obj = _medicamentLogic.ReadElement(new MedicamentSearchModel { Id = model.Id });
|
var obj = _recipeLogic.ReadElement(new RecipeSearchModel { Id = id });
|
||||||
ViewData["Title"] = "Ðåäàêòèðîâàòü ïðåïàðàò";
|
model = new()
|
||||||
return View("CreateMedicament", obj);
|
{
|
||||||
|
RecipeViewModel = obj,
|
||||||
|
Procedures = _procedureLogic.ReadList(null).Select(x => (x, obj.RecipeProcedures.ContainsKey(x.Id))).ToList()
|
||||||
|
};
|
||||||
|
ViewData["Title"] = "Ðåäàêòèðîâàòü ñèìïòîì";
|
||||||
|
return View("CreateRecipe", model);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MedicamentBindingModel medicament = new MedicamentBindingModel
|
var allProcedures = _procedureLogic.ReadList(null);
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
Name = model.Name,
|
|
||||||
Comment = model.Comment ?? string.Empty,
|
|
||||||
SymptomId = model.SymptomId,
|
|
||||||
ProcedureId = model.ProcedureId,
|
|
||||||
};
|
|
||||||
_medicamentLogic.Update(medicament);
|
|
||||||
return RedirectToAction("Medicaments");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
RecipeBindingModel recipe = new RecipeBindingModel
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
ProceduresCount = model.RecipeViewModel.ProceduresCount,
|
||||||
|
Comment = model.RecipeViewModel.Comment,
|
||||||
|
RecipeProcedures = selectedProcedures
|
||||||
|
.ToDictionary(
|
||||||
|
x => x,
|
||||||
|
x => allProcedures.Where(y => y.Id == x) as IProcedureModel
|
||||||
|
)
|
||||||
|
};
|
||||||
|
_recipeLogic.Update(recipe);
|
||||||
|
return RedirectToAction("Recipes");
|
||||||
|
}
|
||||||
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult DeleteRecipe(int id)
|
public IActionResult DeleteRecipe(int id)
|
||||||
{
|
{
|
||||||
var obj = _medicamentLogic.ReadElement(new MedicamentSearchModel { Id = id });
|
var obj = _recipeLogic.ReadElement(new RecipeSearchModel { Id = id });
|
||||||
if (obj != null)
|
if (obj != null)
|
||||||
{
|
{
|
||||||
_medicamentLogic.Delete(new MedicamentBindingModel { Id = obj.Id });
|
_recipeLogic.Delete(new RecipeBindingModel { Id = obj.Id });
|
||||||
}
|
}
|
||||||
return RedirectToAction("Medicaments");
|
return RedirectToAction("Recipes");
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Medicaments()
|
public IActionResult Medicaments()
|
||||||
|
10
Polyclinic/PolyclinicWebAppSuretor/Models/RecipeModel.cs
Normal file
10
Polyclinic/PolyclinicWebAppSuretor/Models/RecipeModel.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using PolyclinicContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace PolyclinicWebAppSuretor.Models
|
||||||
|
{
|
||||||
|
public class RecipeModel
|
||||||
|
{
|
||||||
|
public RecipeViewModel? RecipeViewModel { get; set; }
|
||||||
|
public List<(ProcedureViewModel procedure, bool IsChecked)> Procedures { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,6 @@
|
|||||||
@using PolyclinicContracts.ViewModels
|
@using PolyclinicContracts.ViewModels
|
||||||
@model RecipeViewModel
|
@model RecipeModel
|
||||||
@{
|
|
||||||
|
|
||||||
}
|
|
||||||
<div class="text-center mt-3 mb-3">
|
<div class="text-center mt-3 mb-3">
|
||||||
<h2 class="display-4">@ViewData["Title"]</h2>
|
<h2 class="display-4">@ViewData["Title"]</h2>
|
||||||
</div>
|
</div>
|
||||||
@ -15,65 +13,60 @@
|
|||||||
<h3 class="col-3">
|
<h3 class="col-3">
|
||||||
Количество процедур:
|
Количество процедур:
|
||||||
</h3>
|
</h3>
|
||||||
<input class="col-6" type="text" style="width: 45vh" asp-for="ProceduresCount" />
|
<input class="col-6" type="text" style="width: 45vh" asp-for="RecipeViewModel.ProceduresCount" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="d-flex flex-row mb-5 flex-row justify-content-between align-items-center">
|
<div class="d-flex flex-row mb-5 flex-row justify-content-between align-items-center">
|
||||||
<h3 class="col-3">
|
<h3 class="col-3">
|
||||||
Комментарий:
|
Комментарий:
|
||||||
</h3>
|
</h3>
|
||||||
<textarea class="col-6" id="comment" name="comment" style="width: 45vh" asp-for="Comment">
|
<textarea class="col-6" style="width: 45vh" asp-for="RecipeViewModel.Comment">
|
||||||
|
|
||||||
</textarea>
|
</textarea>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="d-flex flex-row mb-5 justify-content-between align-items-center">
|
<div class="d-flex flex-row mb-5 flex-row justify-content-between align-items-center">
|
||||||
<h3 class="col-3">
|
<h3 class="col-3">
|
||||||
Выбор процедуры:
|
Курс (номер):
|
||||||
</h3>
|
</h3>
|
||||||
<select id="procedureId" name="procedureId" style="width: 45vh">
|
<select id="courseId" style="width: 45vh" asp-for="RecipeViewModel.CourseId">
|
||||||
<option value="">Выберите процедуру/ы</option>
|
<option value="">Выберите номер курса</option>
|
||||||
@foreach (var item in ViewBag.Procedures)
|
@foreach (var course in ViewBag.Courses)
|
||||||
{
|
{
|
||||||
<option value="@item.Id">@item.Name</option>
|
<option value="@course.Id">@course.PillsPerDay</option>
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="proc-list d-flex flex-column overflow-auto" style="max-height: 45vh">
|
<div class="d-flex flex-row mb-5 justify-content-between align-items-center overflow-auto" style="max-height: 20vh">
|
||||||
<table class="table-recipe-create table">
|
<h3 class="col-3">
|
||||||
<thead>
|
Выбор процедуры:
|
||||||
<tr>
|
</h3>
|
||||||
<th>
|
<label value="">Выберите процедуру/ы</label>
|
||||||
Выбранное из процедур:
|
<ol>
|
||||||
</th>
|
@foreach (var item in Model.Procedures)
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach (var item in ViewBag.Procedures)
|
|
||||||
{
|
{
|
||||||
<tr>
|
<li>
|
||||||
<td>Процедура № @item.Id @item.Name</td>
|
@if (item.IsChecked)
|
||||||
<td>
|
{
|
||||||
<svg class="bi-cart-delete" viewBox="0 0 154 164" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<input type="checkbox" id="procedure-@item.procedure.Id" name="selectedProcedures" value="@item.procedure.Id" checked />
|
||||||
<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>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
}
|
}
|
||||||
</tbody>
|
else
|
||||||
</table>
|
{
|
||||||
|
<input type="checkbox" id="procedure-@item.procedure.Id" name="selectedProcedures" value="@item.procedure.Id" />
|
||||||
|
}
|
||||||
|
<label for="procedure-@item.procedure.Id">@item.procedure.Name</label>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="d-flex flex-column mb-5 mt-5">
|
<div class="d-flex flex-column mb-5 mt-5">
|
||||||
<div class="col-8"></div>
|
<div class="col-8"></div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<input type="submit" value="Сохранить" class="button-save-recipe btn" asp-action="Recipes" />
|
<input type="submit" value="Сохранить" class="button-save-recipe btn" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
@ -30,6 +30,9 @@
|
|||||||
<th>
|
<th>
|
||||||
Количество процедур
|
Количество процедур
|
||||||
</th>
|
</th>
|
||||||
|
<th>
|
||||||
|
Номер курса
|
||||||
|
</th>
|
||||||
<th>
|
<th>
|
||||||
Редактировать
|
Редактировать
|
||||||
</th>
|
</th>
|
||||||
@ -41,18 +44,20 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var item in Model)
|
@foreach (var item in Model)
|
||||||
{
|
{
|
||||||
|
<tr>
|
||||||
<td>@item.Id</td>
|
<td>@item.Id</td>
|
||||||
<td>@item.Comment</td>
|
<td>@item.Comment</td>
|
||||||
<td>@item.ProceduresCount</td>
|
<td>@item.ProceduresCount</td
|
||||||
|
<td>@item.CourseId</td>
|
||||||
<td>
|
<td>
|
||||||
<a asp-action="CreateRecipe" asp-route-id="@item.Id">
|
<a asp-action="EditRecipe" asp-route-id="@item.Id">
|
||||||
<svg class="bi-edit-pen" viewBox="0 0 127 127" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<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" />
|
<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>
|
</svg>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<form method="post" asp-route-id="@item.Id">
|
<form method="post" asp-route-id="@item.Id" asp-action="DeleteRecipe">
|
||||||
<button class="btn" 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">
|
<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="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" />
|
||||||
@ -63,6 +68,8 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
|
Loading…
Reference in New Issue
Block a user