сделала создание медикаментов (без симптомов), мучаюсь с созданием рецептов... многие ко многим

This commit is contained in:
Елена Бакальская 2024-05-28 00:17:46 +04:00
parent 171ca6d819
commit 48dd095182
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? CourseId { get; set; }
public int ProceduresCount { get; set; } public int ProceduresCount { get; set; }
public string Comment { get; set; } = string.Empty; 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 ILogger<HomeController> _logger;
private readonly IProcedureLogic _procedureLogic; 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; _logger = logger;
_procedureLogic = procedureLogic; _procedureLogic = procedureLogic;
_medicamentLogic = medicamentLogic;
_recipeLogic = recipeLogic;
_symptomLogic = symptomLogic;
} }
public IActionResult Index() public IActionResult Index()
@ -30,11 +40,151 @@ namespace PolyclinicWebAppSuretor.Controllers
return View(); return View();
} }
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() public IActionResult Medicaments()
{ {
return View(); 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() public IActionResult Procedures()
{ {
List<ProcedureViewModel> procedure = _procedureLogic.ReadList(null); List<ProcedureViewModel> procedure = _procedureLogic.ReadList(null);
@ -45,16 +195,6 @@ namespace PolyclinicWebAppSuretor.Controllers
return View(procedure); return View(procedure);
} }
public IActionResult Recipes()
{
return View();
}
public IActionResult CreateRecipe()
{
return View();
}
[HttpGet] [HttpGet]
[HttpPost] [HttpPost]
public IActionResult CreateProcedure(ProcedureViewModel model) public IActionResult CreateProcedure(ProcedureViewModel model)
@ -115,11 +255,6 @@ namespace PolyclinicWebAppSuretor.Controllers
return RedirectToAction("Procedures"); return RedirectToAction("Procedures");
} }
public IActionResult CreateMedicament()
{
return View();
}
public IActionResult ListCoursesByProcedures() public IActionResult ListCoursesByProcedures()
{ {
return View(); return View();

View File

@ -17,6 +17,15 @@ builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>();
builder.Services.AddTransient<IMedicamentStorage, MedicamentStorage>(); builder.Services.AddTransient<IMedicamentStorage, MedicamentStorage>();
builder.Services.AddTransient<IRecipeStorage, RecipeStorage>(); 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(); var app = builder.Build();
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.

View File

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

View File

@ -1,10 +1,10 @@
@using PolyclinicContracts.ViewModels @using PolyclinicContracts.ViewModels
@model List<RecipeViewModel> @model RecipeViewModel
@{ @{
ViewData["Title"] = "CreateRecipe";
} }
<div class="text-center mt-3 mb-3"> <div class="text-center mt-3 mb-3">
<h2 class="display-4">Создание рецепта</h2> <h2 class="display-4">@ViewData["Title"]</h2>
</div> </div>
<form method="post" class="form-create-recipe d-flex flex-row justify-content-around align-items-center"> <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 class="col-3">
Количество процедур: Количество процедур:
</h3> </h3>
<input class="col-6" type="text" style="width: 45vh" /> <input class="col-6" type="text" style="width: 45vh" asp-for="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"> <textarea class="col-6" id="comment" name="comment" style="width: 45vh" asp-for="Comment">
</textarea> </textarea>
@ -32,14 +32,11 @@
<h3 class="col-3"> <h3 class="col-3">
Выбор процедуры: Выбор процедуры:
</h3> </h3>
<select id="procedureId" name="procedureId" style="width: 45vh"> <select id="procedureId" name="procedureId" style="width: 45vh" multiple>
@* <option value="">Выберите процедуру/ы</option> *@ <option value="">Выберите процедуру/ы</option>
@{ @foreach (var item in ViewBag.Procedures)
int count = 3; {
for (int i = 1; i <= count; i++) <option value="@item.Id">@item.Name</option>
{
<option value="@i">процедура "@i"</option>
}
} }
</select> </select>
</div> </div>
@ -55,21 +52,19 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@{ @foreach (var item in ViewBag.RecipeProcedures)
int cRows = 20; {
for (int i = 1; i <= cRows; i++) <tr>
{ <td>Процедура № @item.Id @item.Name</td>
<tr> <td>
<td>Процедура № @i </td> <svg class="bi-cart-delete" viewBox="0 0 154 164" fill="none" xmlns="http://www.w3.org/2000/svg">
<td> <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" />
<svg class="bi-cart-delete" viewBox="0 0 154 164" fill="none" xmlns="http://www.w3.org/2000/svg"> <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="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="M121 36L101.582 55L75 31" 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" /> </svg>
<path d="M121 36L101.582 55L75 31" stroke="#D10000" stroke-width="8" stroke-linecap="round" /> </td>
</svg> </tr>
</td>
</tr>
}
} }
</tbody> </tbody>
</table> </table>

View File

@ -1,8 +1,6 @@
@using PolyclinicContracts.ViewModels @using PolyclinicContracts.ViewModels
@model List<MedicamentViewModel> @model List<MedicamentViewModel>
@{ @ViewData["Title"] = "Medicaments";
ViewData["Title"] = "Medicaments";
}
<div class="text-center"> <div class="text-center">
<h1 class="display-4">Препараты</h1> <h1 class="display-4">Препараты</h1>
@ -31,7 +29,7 @@
Симптом Симптом
</th> </th>
<th> <th>
Рецепт (номер) Процедура
</th> </th>
<th> <th>
Комментарий Комментарий
@ -49,26 +47,28 @@
{ {
<td>@item.Id</td> <td>@item.Id</td>
<td>@item.Name</td> <td>@item.Name</td>
<td>@item.SymptomId.</td> <td>@item.SymptomName</td>
<td>@item.ProcedureName</td>
<td>@item.Comment</td>
<td> <td>
3 <a asp-action="EditMedicament" asp-route-id="@item.Id">
</td>
<td>
При особом неврозе употребляйте каждый день и спина не будет болеть
</td>
<td>
<a asp-action="CreateMedicament">
<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>
<svg class="bi-cart-delete" viewBox="0 0 154 164" fill="none" xmlns="http://www.w3.org/2000/svg"> <form method="post" asp-action="DeleteMedicament" asp-route-id="@item.Id">
<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" /> <button class="btn" type="submit">
<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" /> <svg class="bi-cart-delete" viewBox="0 0 154 164" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M121 36L101.582 55L75 31" 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" />
</svg> <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> </td>
} }
</tbody> </tbody>

View File

@ -49,7 +49,7 @@
</td> </td>
<td> <td>
<form method="post" asp-action="DeleteProcedure" asp-route-id="@item.Id"> <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"> <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" />
<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="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 @using PolyclinicContracts.ViewModels
@model List<RecipeViewModel> @model List<RecipeViewModel>
@{
ViewData["Title"] = "Recipes";
}
<div class="text-center"> <div class="text-center">
<h1 class="display-4">Рецепты</h1> <h1 class="display-4">Рецепты</h1>
</div> </div>
@ -42,29 +39,32 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<td> @foreach (var item in Model)
1 {
</td> <td>@item.Id</td>
<td> <td>@item.Comment</td>
Это процедура для вашей спины <td>@item.ProceduresCount</td>
</td> <td>
<td> <a asp-action="CreateRecipe" asp-route-id="@item.Id">
4 <svg class="bi-edit-pen" viewBox="0 0 127 127" fill="none" xmlns="http://www.w3.org/2000/svg">
</td> <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" />
<td> </svg>
<a asp-action="CreateRecipe"> </a>
<svg class="bi-edit-pen" viewBox="0 0 127 127" fill="none" xmlns="http://www.w3.org/2000/svg"> </td>
<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" /> <td>
</svg> <form method="post" asp-route-id="@item.Id">
</a> <button class="btn" type="submit">
</td> <svg class="bi-cart-delete" viewBox="0 0 154 164" fill="none" xmlns="http://www.w3.org/2000/svg">
<td> <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" />
<svg class="bi-cart-delete" viewBox="0 0 154 164" fill="none" xmlns="http://www.w3.org/2000/svg"> <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="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="M121 36L101.582 55L75 31" 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" /> </svg>
<path d="M121 36L101.582 55L75 31" stroke="#D10000" stroke-width="8" stroke-linecap="round" /> </button>
</svg> </form>
</td>
</td>
}
</tbody> </tbody>
</table> </table>
} }