жизнь с чистого листа

This commit is contained in:
ValAnn 2024-05-25 18:19:13 +04:00
parent 2efc894170
commit 9159f52f40
36 changed files with 946 additions and 269 deletions

View File

@ -106,7 +106,7 @@ namespace HospitalBusinessLogic.BusinessLogics
{
throw new ArgumentNullException("Возраст пациента должен быть больше 0", nameof(model.FIO));
}*/ //TODO
_logger.LogInformation("Patient. Login:{Login}. PhoneNumber:{PhoneNumber}. Password:{Password}. BirthDate:{BirthDate}. DoctorId:{DoctorId}. Id:{ Id}", model.FIO, model.BirthDate, model.DoctorId, model.Id);
//_logger.LogInformation("Patient. Login:{Login}. PhoneNumber:{PhoneNumber}. Password:{Password}. BirthDate:{BirthDate}. DoctorId:{DoctorId}. Id:{ Id}", model.FIO, model.BirthDate, model.DoctorId, model.Id);
var element = _patientStorage.GetElement(new PatientSearchModel
{
FIO = model.FIO,

View File

@ -1,50 +1,70 @@
using System;
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicContracts;
using HospitalContracts.SearchModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using HospitalDataModels.Models;
using HospitalContracts.BindingModels;
using HospitalContracts.ViewModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.SearchModels;
using HospitalContracts.BusinessLogicContracts;
namespace HospitalBusinessLogic.BusinessLogics
{
public class PharmacistLogic : IPharmacistLogic
{
private readonly ILogger _logger;
private readonly IPharmacistStorage _pharmacistStorage;
public PharmacistLogic(ILogger<PharmacistLogic> logger, IPharmacistStorage
pharmacistStorage)
private readonly IPharmacistStorage _PharmacistStorage;
public PharmacistLogic(ILogger<PharmacistLogic> logger, IPharmacistStorage PharmacistStorage)
{
_logger = logger;
_pharmacistStorage = pharmacistStorage;
_PharmacistStorage = PharmacistStorage;
}
public List<PharmacistViewModel>? ReadList(PharmacistSearchModel? model)
public bool Create(PharmacistBindingModel model)
{
_logger.LogInformation("ReadList. FIO:{FIO}. Id:{ Id}", model?.FIO, model?.Id);
var list = model == null ? _pharmacistStorage.GetFullList() :
_pharmacistStorage.GetFilteredList(model);
if (list == null)
CheckModel(model);
if (_PharmacistStorage.Insert(model) == null)
{
_logger.LogWarning("ReadList return null list");
return null;
_logger.LogWarning("Insert operation failed");
return false;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
return true;
}
public bool Update(PharmacistBindingModel model)
{
CheckModel(model);
if (_PharmacistStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(PharmacistBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_PharmacistStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public PharmacistViewModel? ReadElement(PharmacistSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. FIO:{FIO}.Id:{ Id}", model.FIO, model.Id);
var element = _pharmacistStorage.GetElement(model);
_logger.LogInformation("ReadElement. Login:{Login}. PhoneNumber:{PhoneNumber}. Id:{ Id}", model.Login, model.PhoneNumber, model.Id);
var element = _PharmacistStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
@ -53,39 +73,21 @@ namespace HospitalBusinessLogic.BusinessLogics
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(PharmacistBindingModel model)
public List<PharmacistViewModel>? ReadList(PharmacistSearchModel? model)
{
CheckModel(model);
if (_pharmacistStorage.Insert(model) == null)
_logger.LogInformation("ReadList. PharmacistId:{Id}", model?.Id);
var list = model == null ? _PharmacistStorage.GetFullList() : _PharmacistStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("Insert operation failed");
return false;
_logger.LogWarning("ReadList return null list");
return null;
}
return true;
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public bool Update(PharmacistBindingModel model)
{
CheckModel(model);
if (_pharmacistStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(PharmacistBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_pharmacistStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(PharmacistBindingModel model, bool withParams =
true)
private void CheckModel(PharmacistBindingModel model, bool withParams = true)
{
if (model == null)
{
@ -95,33 +97,28 @@ namespace HospitalBusinessLogic.BusinessLogics
{
return;
}
if (string.IsNullOrEmpty(model.FIO))
{
throw new ArgumentNullException("Нет ФИО клиента",
nameof(model.FIO));
}
if (string.IsNullOrEmpty(model.Login))
{
throw new ArgumentNullException("Нет Email клиента",
nameof(model.Login));
throw new ArgumentNullException("Нет логина врача", nameof(model.Login));
}
if (string.IsNullOrEmpty(model.PhoneNumber))
{
throw new ArgumentNullException("Нет номера телефона врача", nameof(model.PhoneNumber));
}
if (string.IsNullOrEmpty(model.Password))
{
throw new ArgumentNullException("Нет пароля клиента",
nameof(model.Password));
throw new ArgumentNullException("Нет пароля врача", nameof(model.Password));
}
_logger.LogInformation("Pharmacist. FIO:{FIO}." +
"Email:{ Email}. Password:{ Password}. Id: { Id} ", model.FIO, model.Login, model.Password, model.Id);
var element = _pharmacistStorage.GetElement(new PharmacistSearchModel
_logger.LogInformation("Pharmacist. Login:{Login}. PhoneNumber:{PhoneNumber}. Password:{Password}. Id:{ Id}", model.Login, model.PhoneNumber, model.Password, model.Id);
var element = _PharmacistStorage.GetElement(new PharmacistSearchModel
{
Login = model.Login,
Password = model.Password
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Клиент с таким логином уже есть");
throw new InvalidOperationException("Врач с таким именем уже есть");
}
}
}
}

View File

@ -99,7 +99,7 @@ true)
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentNullException("Нет названия услуги",
throw new ArgumentNullException("Нет названия процедуры",
nameof(model.Name));
}
@ -110,7 +110,7 @@ true)
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Услуга с таким названием уже есть");
throw new InvalidOperationException("Процедура с таким названием уже есть");
}
}
}

View File

@ -13,7 +13,6 @@ namespace HospitalContracts.BindingModels
public string Description { get; set; } = string.Empty;
public int PharmacistId { get; set; }
}
}

View File

@ -9,11 +9,12 @@ namespace HospitalContracts.BindingModels
{
public class PharmacistBindingModel : IPharmacistModel
{
public string FIO { get; set; } = string.Empty;
public int Id { get; set; }
public string FIO { get; set; } = string.Empty;
public string Login { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public string PhoneNumber { get; set; } = string.Empty;
public int Id { get; set; }
}
}

View File

@ -17,17 +17,17 @@ namespace HospitalDatabaseImplement.Implements
{
public PharmacistViewModel? GetElement(PharmacistSearchModel model)
{
if (!model.Id.HasValue)
if ((string.IsNullOrEmpty(model.Login) && !model.Id.HasValue))
{
return null;
}
using var context = new HospitalDatabase();
return context.Pharmacists
.Include(x => x.Medicines)
.Include(x => x.Procedures)
.Include(x => x.DescriptionProcedures)
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
?.GetViewModel;
.FirstOrDefault(x =>
(!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Login) || x.Login == model.Login) &&
(string.IsNullOrEmpty(model.Password) || x.Password == model.Password))
?.GetViewModel;
}
public List<PharmacistViewModel> GetFilteredList(PharmacistSearchModel model)
@ -59,19 +59,19 @@ namespace HospitalDatabaseImplement.Implements
public PharmacistViewModel? Insert(PharmacistBindingModel model)
{
var newDoctor = Pharmacist.Create(model);
if (newDoctor == null)
var newPharmacist = Pharmacist.Create(model);
if (newPharmacist == null)
{
return null;
}
using var context = new HospitalDatabase();
context.Pharmacists.Add(newDoctor);
context.Pharmacists.Add(newPharmacist);
context.SaveChanges();
return context.Pharmacists
.Include(x => x.Medicines)
.Include(x => x.Procedures)
.Include(x => x.DescriptionProcedures)
.FirstOrDefault(x => x.Id == newDoctor.Id)
.FirstOrDefault(x => x.Id == newPharmacist.Id)
?.GetViewModel;
}

View File

@ -37,8 +37,6 @@ namespace HospitalDatabaseImplement.Models
return new DescriptionProcedure()
{
Id = model.Id,
Description = model.Description,
PharmacistId = model.PharmacistId,
Pharmacist = context.Pharmacists.FirstOrDefault(x => x.Id == model.PharmacistId)

View File

@ -31,7 +31,7 @@ namespace HospitalDatabaseImplement.Implementss
public List<DiseaseViewModel> GetFilteredList(DiseaseSearchModel model)
{
using var context = new HospitalDatabase();
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
if (string.IsNullOrEmpty(model.Name) && model.Id.HasValue)
{
return context.Diseases
.Include(x => x.Recipes)

View File

@ -26,7 +26,7 @@ namespace HospitalDatabaseImplement.Implementss
public List<RecipeViewModel> GetFilteredList(RecipeSearchModel model)
{
using var context = new HospitalDatabase();
if (!model.Id.HasValue)
if (model.Id.HasValue)
{
return context.Recipes
.Include(x => x.Doctor)

View File

@ -60,6 +60,7 @@ namespace HospitalDatabaseImplement.Models
Id = model.Id,
Name = model.Name,
Price = model.Price,
CountryOrigin = model.CountryOrigin,
Recipes = model.MedicineRecipes.Select(x => new
RecipeMedicine
{

View File

@ -50,7 +50,8 @@ namespace HospitalDatabaseImplement.Models
{
Id = model.Id,
Login = model.Login,
PhoneNumber = model.PhoneNumber,
FIO = model.FIO,
PhoneNumber = model.PhoneNumber,
Password = model.Password
};
}

View File

@ -49,6 +49,11 @@ namespace HospitalDatabaseImplement.Models
return new Procedure()
{
Id = model.Id,
PharmacistId = model.PharmacistId,
Pharmacist = context.Pharmacists.First(x => x.Id == model.PharmacistId),
DescriptionProcedureId = model.DescriptionProcedureId,
DescriptionProcedure = context.DescriptionProcedures.First(x => x.Id == model.DescriptionProcedureId),
Date = model.Date,
Name = model.Name,
Medicines = model.ProcedureMedicines.Select(x => new ProcedureMedicine
{

View File

@ -75,6 +75,7 @@ namespace HospitalDatabaseImplement.Modelss
{
Id = Id,
IssueDate = IssueDate,
Description = Description,
RecipePatients = RecipePatients
};

View File

@ -33,8 +33,7 @@ namespace HospitalDoctorApp.Controllers
{
return Redirect("~/Home/Enter");
}
return
View(APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doctorId={APIClient.Doctor.Id}"));
return View(APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doctorId={APIClient.Doctor.Id}"));
}
public IActionResult IndexDiseases()
@ -43,8 +42,7 @@ View(APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doct
{
return Redirect("~/Home/Enter");
}
return
View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?diseaseId={APIClient.Doctor.Id}"));
return View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?diseaseId={APIClient.Doctor.Id}"));
}
@ -153,11 +151,12 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
{
return Redirect("~/Home/");
}
ViewBag.Procedures = APIClient.GetRequest<List<ProcedureViewModel>>($"api/procedure/getprocedures");
return View();
}
public IActionResult CreateRecipe()
{
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>("api/disease/getdiseaselist");
ViewBag.Diseases = APIClient.GetRequest<List<DiseaseViewModel>>("api/disease/getdiseases");
if (APIClient.Doctor == null)
{
return Redirect("~/Home/");
@ -170,31 +169,35 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
{
return Redirect("~/Home/");
}
return View(); return View();
return View();
}
[HttpPost]
public void CreatePatient(string name, string address, DateTime patientdate)
public void CreatePatient(string fio, string address, DateTime patientdate, List<int> procedures)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(address))
{
throw new Exception("Ошибка в введенных данных");
}
Dictionary<int, IProcedureModel> produresDict = new Dictionary<int, IProcedureModel>();
foreach (int procedure in procedures)
{
produresDict.Add(procedure, new ProcedureSearchModel { Id = procedure } as IProcedureModel);
}
APIClient.PostRequest("api/patient/createpatient", new PatientBindingModel
{
FIO = name,
FIO = fio,
BirthDate = patientdate,
Address = address,
DoctorId = APIClient.Doctor.Id
DoctorId = APIClient.Doctor.Id,
PatientProcedures = produresDict
});
Response.Redirect("Index");
}
[HttpPost]
public void CreateRecipe(string description, DateTime issueDate)
public void CreateRecipe(string description, DateTime date, int disease)
{
if (APIClient.Doctor == null)
{
@ -207,8 +210,9 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
APIClient.PostRequest("api/recipe/createrecipe", new RecipeBindingModel
{
Description = description,
IssueDate = issueDate,
DoctorId = APIClient.Doctor.Id
IssueDate = date,
DoctorId = APIClient.Doctor.Id,
DiseaseId = disease
});
Response.Redirect("IndexRecipes");
}
@ -230,9 +234,8 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
APIClient.PostRequest("api/disease/createdisease", new DiseaseBindingModel
{
Name = name,
DoctorId = doctorId,
Description = description
DoctorId = APIClient.Doctor.Id,
Description = description
});
Response.Redirect("IndexDiseases");
}
@ -272,7 +275,24 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doctorid={APIClient.Doctor.Id}");
return View();
}
public IActionResult DeleteDisease()
[HttpPost]
public void DeleteRecipe(int recipe)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
APIClient.PostRequest("api/recipe/deleterecipe", new RecipeBindingModel
{
Id = recipe
});
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipes?doctorid={APIClient.Doctor.Id}");
Response.Redirect("IndexRecipes");
}
public IActionResult DeleteDisease()
{
if (APIClient.Doctor == null)
{
@ -282,19 +302,6 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
return View();
}
[HttpPost]
public void DeleteRecipe(int recipe)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
APIClient.PostRequest("api/recipe/deleterecipe", new RecipeBindingModel
{
Id = recipe
});
Response.Redirect("IndexRecipes");
}
[HttpPost]
public void DeleteDisease(int disease)
{
@ -348,11 +355,13 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
return Redirect("~/Home/Enter");
}
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doctorid={APIClient.Doctor.Id}");
return View();
ViewBag.Diseases = APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?diseaseId={APIClient.Doctor.Id}");
return View();
}
[HttpPost]
public void UpdateRecipe(int recipe, string description, DateTime issuedate)
public void UpdateRecipe(int recipe, string description, DateTime date, int disease)
{
if (APIClient.Doctor == null)
{
@ -367,8 +376,9 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
{
Id = recipe,
Description = description,
IssueDate = issuedate
IssueDate = date,
DiseaseId = disease
});
Response.Redirect("IndexRecipes");
}
@ -404,7 +414,7 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
});
Response.Redirect("IndexDisease");
Response.Redirect("IndexDiseases");
}
#endregion

View File

@ -18,7 +18,7 @@
<label class="u-label u-text-custom-color-1 u-label-2">Дата рождения</label>
<input type="date"
placeholder="Введите дату рождения"
name="birthdate"
name="patientdate"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
@ -28,6 +28,17 @@
name="address"
class="u-input u-input-rectangle" />
</div>
<div class="row">
<div class="col-4">Процедуры:</div>
<div class="col-8">
<select name="procedures" class="form-control" multiple size="6" id="procedures">
@foreach (var procedure in ViewBag.Procedures)
{
<option value="@procedure.Id">@procedure.Name</option>
}
</select>
</div>
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>

View File

@ -18,11 +18,12 @@
<select id="disease" name="disease" class="form-control" asp-items="@(new SelectList(@ViewBag.Diseases, "Id", "Name"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Дата назначения:</div>
<div class="col-8">
<input type="datetime" name="date" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Дата создания</label>
<input type="date"
placeholder="Введите дату рождения"
name="date"
class="u-input u-input-rectangle" />
</div>
<div class="row">
<div class="col-8"></div>
@ -34,7 +35,7 @@
</form>
<script>
$('#disease').on('change', function () {
//check();
check();
});
function check() {
if (snack) {

View File

@ -1,28 +1,18 @@
@{
ViewData["Title"] = "CreateDisease";
ViewData["Title"] = "DeleteDisease";
}
<head>
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
</head>
<div class="text-center">
<h2 class="display-4">Удаление болезни</h2>
</div>
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Название болезни</label>
<input type="text"
placeholder="Введите название болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Начало</label>
<input type="text"
placeholder="Введите описание болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>
<div class="row">
<div class="col-4">Болезни:</div>
<div class="col-8">
<select id="disease" name="disease" class="form-control" asp-items="@(new SelectList(@ViewBag.Diseases, "Id", "Name"))"></select>
</div>
</div>
<div class="row">
<div class="col-4"></div>
<div class="col-8"><input type="submit" value="Удалить" class="btn btn-danger" /></div>
</div>
</form>

View File

@ -8,7 +8,7 @@
<div class="row">
<div class="col-4">Пациенты:</div>
<div class="col-8">
<select id="pacient" name="pacient" class="form-control" asp-items="@(new SelectList(@ViewBag.Pacients, "Id", "FIO"))"></select>
<select id="patient" name="patient" class="form-control" asp-items="@(new SelectList(@ViewBag.Patients, "Id", "FIO"))"></select>
</div>
</div>
<div class="row">

View File

@ -8,7 +8,7 @@
<div class="row">
<div class="col-4">Рецепт:</div>
<div class="col-8">
<select id="recipe" name="recipe" class="form-control" ></select>
<select id="recipe" name="recipe" class="form-control" asp-items="@(new SelectList(@ViewBag.Recipes, "Id", "Description"))"></select>
</div>
</div>
<div class="row">

View File

@ -20,7 +20,7 @@
<p>
<a asp-action="UpdatePatient">Редактировать пациента</a>
<a asp-action="DeletePatient">Удалить пациента</a>
<a asp-action="AddProcedureToPatient">Связать пацииента и процедуру</a>
<a asp-action="AddProcedureToPatient">Связать пациента и процедуру</a>
</p>
<p>
<a asp-action="CreatePatient">Создать пациента</a>
@ -32,10 +32,10 @@
Номер
</th>
<th>
Название
ФИО
</th>
<th>
Дата
Дата рождения
</th>
</tr>
@ -52,7 +52,7 @@
@Html.DisplayFor(modelItem => item.FIO)
</td>
<td>
@Html.DisplayFor(modelItem => item.Address)
@Html.DisplayFor(modelItem => item.BirthDate)
</td>
</tr>

View File

@ -18,11 +18,11 @@
return;
}
<p>
<a asp-action="UpdateRecipe">Редактировать болезнь</a>
<a asp-action="DeleteRecipe">Удалить болезнь</a>
<a asp-action="UpdateDisease">Редактировать болезнь</a>
<a asp-action="DeleteDisease">Удалить болезнь</a>
</p>
<p>
<a asp-action="CreateRecipe">Создать болезнь</a>
<a asp-action="CreateDisease">Создать болезнь</a>
</p>
<table class="table">
<thead>

View File

@ -20,7 +20,7 @@
<p>
<a asp-action="UpdateRecipe">Редактировать рецепт</a>
<a asp-action="DeleteRecipe">Удалить рецепт</a>
<a asp-action="LinkPatientAndProcedure">Связать рецепт и пациента</a>
<a asp-action="LinkPatientAndProcedure">Связать рецепт(процедуру?) и пациента</a>
</p>
<p>
<a asp-action="CreateRecipe">Создать рецепт</a>

View File

@ -1,28 +1,57 @@
@{
ViewData["Title"] = "CreateDisease";
ViewData["Title"] = "UpdateDisease";
}
<head>
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
</head>
<div class="text-center">
<h2 class="display-4">Редактирование болезни</h2>
</div>
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Название болезни</label>
<input type="text"
placeholder="Введите название болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Начало</label>
<input type="text"
placeholder="Введите описание болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
<div class="row">
<div class="col-4">Болезнь:</div>
<div class="col-8">
<select id="disease" name="disease" class="form-control" asp-items="@(new SelectList(@ViewBag.Diseases, "Id", "Name"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8">
<input type="text" id="name" name="name" />
</div>
</div>
<div class="row">
<div class="col-4">Описание:</div>
<div class="col-8">
<input type="text" id="description" name="description" />
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
</div>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
</form>
<script>
function check() {
var disease = $('#disease').val();
$("#disease option:selected").removeAttr("selected");
if (disease) {
$.ajax({
method: "GET",
url: "/Home/GetDisease",
data: { diseaseId: disease },
success: function (result) {
console.log(result.item2);
$('#name').val(result.Name);
$('#description').val(result.Description);
}
});
};
}
check();
$('#disease').on('change', function () {
check();
});
</script>

View File

@ -11,22 +11,24 @@
<div class="row">
<div class="col-4">Пациент:</div>
<div class="col-8">
<select id="patient" name="patient" class="form-control" asp-items="@(new SelectList(@ViewBag.Pacients, "Id", "FIO"))"></select>
<select id="patient" name="patient" class="form-control" asp-items="@(new SelectList(@ViewBag.Patients, "Id", "FIO"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">ФИО:</div>
<div class="col-8"><input type="text" name="name" id="name" class="form-control" /></div>
<div class="col-8"><input type="text" name="fio" id="fio" class="form-control" /></div>
</div>
<div class="row">
<div class="col-4">Дата рождения:</div>
<div class="col-8">
<input type="datetime" id="datetime" name="date" />
<input type="datetime" id="birthdate" name="birthdate" />
</div>
</div>
<div class="row">
<div class="col-4">Адрес:</div>
<div class="col-8"><input type="text" name="address" id="name" class="form-control" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
@ -45,7 +47,8 @@
data: { Id: patient },
success: function (result) {
$('#fio').val(result.item1.FIO);
$('#datebirth').val(result.item1.datebirth);
$('#datebirth').val(result.item1.BirthDate);
$('#address').val(result.item1.Address);
}
});
};

View File

@ -11,18 +11,28 @@
<div class="row">
<div class="col-4">Рецепт:</div>
<div class="col-8">
<select id="recipe" name="recipe" class="form-control" asp-items="@(new SelectList(@ViewBag.Recipes, "Id", "Description"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8"><input type="text" name="name" id="name" class="form-control" /></div>
</div>
<div class="row">
<div class="col-4">Описание:</div>
<div class="col-8"><input type="text" id="family" name="family" class="form-control" /></div>
</div>
<div class="row">
<div class="col-4">Описание:</div>
<div class="col-8">
<input type="text" name="description" />
</div>
</div>
<div class="row">
<div class="col-4">Болезнь:</div>
<div class="col-8">
<select id="disease" name="disease" class="form-control" asp-items="@(new SelectList(@ViewBag.Diseases, "Id", "Name"))"></select>
</div>
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Дата создания</label>
<input type="date"
placeholder="Введите дату рождения"
name="date"
class="u-input u-input-rectangle" />
</div>
<div class="row">
@ -31,3 +41,27 @@
</div>
</form>
@section Scripts
{
<script>
function check() {
var recipe = $('#recipe').val();
if (recipe) {
$.ajax({
method: "GET",
url: "/Home/GetRecipe",
data: { Id: recipe },
success: function (result) {
$('#name').val(result.item1.Name);
$('#description').val(result.item1.Description);
$('#address').val(result.item1.Address);
}
});
};
}
check();
$('#patient').on('change', function () {
check();
});
</script>
}

View File

@ -4,9 +4,12 @@ using PharmacistApp.Models;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using HospitalDoctorApp;
using HospitalPharmacistApp;
using HospitalDataModels.Models;
using HospitalContracts.SearchModels;
using System.Text;
using NPOI.Util;
namespace HospitalPharmacistApp.Controllers
namespace HospitalDoctorApp.Controllers
{
public class HomeController : Controller
{
@ -17,23 +20,21 @@ namespace HospitalPharmacistApp.Controllers
_logger = logger;
}
[HttpGet]
public IActionResult CreateMedicine()
{
return View();
}
[HttpGet]
public IActionResult CreateProcedure()
{
return View();
}
[HttpGet]
public IActionResult CreateDescriptionProcedure()
{
return View();
}
//[HttpGet]
//public IActionResult CreateMedicine()
//{
// return View();
//}
//[HttpGet]
//public IActionResult CreateProcedure()
//{
// return View();
//}
//[HttpGet]
//public IActionResult CreateDescriptionProcedure()
//{
// return View();
//}
public IActionResult Index()
{
@ -41,18 +42,538 @@ namespace HospitalPharmacistApp.Controllers
{
return Redirect("~/Home/Enter");
}
return
View(APIPharmacist.GetRequest<List<PatientViewModel>>($"api/visit/getpatients?PharmacistId={APIPharmacist.Pharmacist.Id}"));
return View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines?pharmacistId={APIPharmacist.Pharmacist.Id}"));
}
public IActionResult IndexRecipes()
public IActionResult CreateMedicine()
{
if (APIPharmacist.Pharmacist == null)
{
return Redirect("~/Home/Enter");
}
return View();
}
[HttpPost]
public void CreateMedicine(string name, string price)
{
if (APIPharmacist.Pharmacist == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
StringBuilder st = new StringBuilder(price);
for (int i = 0; i < price.Length; i++)
{
if (price[i] == '.')
st[i] = ',';
}
price = st.ToString();
double _price;
try
{
_price = Convert.ToDouble(price);
}
catch (Exception ex)
{
throw new Exception("Ошибка в введенных данных");
}
if (string.IsNullOrEmpty(name) || _price <= 0)
{
throw new Exception("Ошибка в введенных данных");
}
APIPharmacist.PostRequest("api/medicine/createmedicine", new MedicineBindingModel
{
Name = name,
Price = Math.Round(_price, 2),
PharmacistId = APIPharmacist.Pharmacist.Id
});
Response.Redirect("Index");
}
public IActionResult DeleteMedicine()
{
if (APIPharmacist.Pharmacist == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Medicines = APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines?pharmacistid={APIPharmacist.Pharmacist.Id}");
return View();
}
[HttpPost]
public void DeleteMedicine(int medicine)
{
if (APIPharmacist.Pharmacist == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
APIPharmacist.PostRequest("api/medicine/deletemedicine", new MedicineBindingModel
{
Id = medicine
});
Response.Redirect("Index");
}
public IActionResult UpdateMedicine()
{
if (APIPharmacist.Pharmacist == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Medicines = APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines?pharmacistid={APIPharmacist.Pharmacist.Id}");
return View();
}
[HttpPost]
public void UpdateMedicine(int medicine, string name, string price)
{
if (APIPharmacist.Pharmacist == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
StringBuilder st = new StringBuilder(price);
for (int i = 0; i < price.Length; i++)
{
if (price[i] == '.')
st[i] = ',';
}
price = st.ToString();
double _price;
try
{
_price = Convert.ToDouble(price);
}
catch (Exception ex)
{
throw new Exception("Ошибка в введенных данных");
}
if (string.IsNullOrEmpty(name) || _price <= 0)
{
throw new Exception("Ошибка в введенных данных");
}
APIPharmacist.PostRequest("api/medicine/updatemedicine?isconnection=false", new MedicineBindingModel
{
Id = medicine,
Name = name,
Price = Math.Round(_price, 2),
PharmacistId = APIPharmacist.Pharmacist.Id,
});
Response.Redirect("Index");
}
public IActionResult MedicineAnimals()
{
if (APIPharmacist.Pharmacist == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Medicines = APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines?pharmacistid={APIPharmacist.Pharmacist.Id}");
ViewBag.Animals = APIPharmacist.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist");
return View();
}
[HttpPost]
public void MedicineAnimals(int medicine, string name, string price,
List<int> animals)
{
if (APIPharmacist.Pharmacist == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
StringBuilder st = new StringBuilder(price);
for (int i = 0; i < price.Length; i++)
{
if (price[i] == '.')
st[i] = ',';
}
price = st.ToString();
double _price;
try
{
_price = Convert.ToDouble(price);
}
catch (Exception ex)
{
throw new Exception("Ошибка в введенных данных");
}
if (string.IsNullOrEmpty(name) || _price <= 0)
{
throw new Exception("Ошибка в введенных данных");
}
Dictionary<int, IRecipeModel> a = new Dictionary<int, IRecipeModel>();
foreach (int animal in animals)
{
a.Add(animal, new RecipeSearchModel { Id = animal } as IRecipeModel);
}
APIPharmacist.PostRequest("api/medicine/updatemedicine?isconnection=true", new MedicineBindingModel
{
Id = medicine,
Name = name,
Price = Math.Round(_price, 2),
PharmacistId = APIPharmacist.Pharmacist.Id,
MedicineRecipes = a
});
Response.Redirect("Index");
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
[HttpGet]
public Tuple<MedicineViewModel, List<string>>? GetMedicine(int medicineId)
{
if (APIPharmacist.Pharmacist == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
var result = APIPharmacist.GetRequest<Tuple<MedicineViewModel, List<string>>>($"api/medicine/getmedicine?medicineid={medicineId}");
if (result == null)
{
return default;
}
return result;
}
[HttpGet]
public RecipeViewModel? GetAnimal(int animalId)
{
if (APIPharmacist.Pharmacist == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
var result = APIPharmacist.GetRequest<RecipeViewModel>($"api/animal/getanimal?animalid={animalId}");
return result;
}
public IActionResult IndexProcedures()
{
if (APIPharmacist.Pharmacist == null)
{
return Redirect("~/Home/Enter");
}
return
View(APIPharmacist.GetRequest<List<RecipeViewModel>>($"api/animal/getrecipelist?PharmacistId={APIPharmacist.Pharmacist.Id}"));
View(APIPharmacist.GetRequest<List<ProcedureViewModel>>($"api/procedure/getprocedures?pharmacistid={APIPharmacist.Pharmacist.Id}"));
}
public IActionResult CreateProcedure()
{
if (APIPharmacist.Pharmacist == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Descriptions = APIPharmacist.GetRequest<List<DescriptionProcedureViewModel>>($"api/descriptionprocedure/getdescriptionprocedurees?pharmacistid={APIPharmacist.Pharmacist.Id}");
ViewBag.Medicines = APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines");
return View();
}
[HttpPost]
public void CreateProcedure(string name, string price, List<int> medicines, int descriptionofprocedure)
{
if (APIPharmacist.Pharmacist == null)
{
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
}
StringBuilder st = new StringBuilder(price);
for (int i = 0; i < price.Length; i++)
{
if (price[i] == '.')
st[i] = ',';
}
price = st.ToString();
double _price;
try
{
_price = Convert.ToDouble(price);
}
catch (Exception ex)
{
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
}
if (string.IsNullOrEmpty(name) || _price <= 0)
{
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
}
Dictionary<int, IMedicineModel> a = new Dictionary<int, IMedicineModel>();
foreach (int medicine in medicines)
{
a.Add(medicine, new MedicineSearchModel { Id = medicine } as IMedicineModel);
}
APIPharmacist.PostRequest("api/procedure/createprocedure", new ProcedureBindingModel
{
Name = name,
PharmacistId = APIPharmacist.Pharmacist.Id,
ProcedureMedicines = a,
DescriptionProcedureId = descriptionofprocedure
});
Response.Redirect("Index");
}
public IActionResult DeleteProcedure()
{
if (APIPharmacist.Pharmacist == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Services = APIPharmacist.GetRequest<List<ProcedureViewModel>>($"api/procedure/getprocedures?pharmacistid={APIPharmacist.Pharmacist.Id}");
return View();
}
[HttpPost]
public void DeleteProcedure(int service)
{
if (APIPharmacist.Pharmacist == null)
{
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
}
APIPharmacist.PostRequest("api/procedure/deleteprocedure", new ProcedureBindingModel
{
Id = service
});
Response.Redirect("Index");
}
public IActionResult UpdateProcedure()
{
if (APIPharmacist.Pharmacist == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Services = APIPharmacist.GetRequest<List<ProcedureViewModel>>($"api/procedure/getprocedures?pharmacistid={APIPharmacist.Pharmacist.Id}");
ViewBag.Medicines = APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines");
return View();
}
[HttpPost]
public void UpdateProcedure(int service, string name, string price,
List<int> medicines)
{
if (APIPharmacist.Pharmacist == null)
{
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
}
StringBuilder st = new StringBuilder(price);
for (int i = 0; i < price.Length; i++)
{
if (price[i] == '.')
st[i] = ',';
}
price = st.ToString();
double _price;
try
{
_price = Convert.ToDouble(price);
}
catch (Exception ex)
{
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
}
if (string.IsNullOrEmpty(name) || _price <= 0)
{
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
}
Dictionary<int, IMedicineModel> a = new Dictionary<int, IMedicineModel>();
foreach (int medicine in medicines)
{
a.Add(medicine, new MedicineSearchModel { Id = medicine } as IMedicineModel);
}
APIPharmacist.PostRequest("api/procedure/updateprocedure", new ProcedureBindingModel
{
Id = service,
Name = name,
PharmacistId = APIPharmacist.Pharmacist.Id,
ProcedureMedicines = a
});
Response.Redirect("Index");
}
[HttpGet]
public Tuple<ProcedureViewModel, List<string>>? GetService(int serviceId)
{
if (APIPharmacist.Pharmacist == null)
{
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
}
var result = APIPharmacist.GetRequest<Tuple<ProcedureViewModel, List<string>>>($"api/service/getservice?serviceid={serviceId}");
if (result == null)
{
return default;
}
return result;
}
public IActionResult IndexDescriptionProcedures()
{
if (APIPharmacist.Pharmacist == null)
{
return Redirect("~/Home/Enter");
}
var res = APIPharmacist.GetRequest<List<DescriptionProcedureViewModel>>($"api/descriptionprocedure/getdescriptionprocedurees?pharmacistid={APIPharmacist.Pharmacist.Id}");
return
View(res);
}
[HttpGet]
public IActionResult CreateDescriptionProcedure()
{
ViewBag.Procedures = APIPharmacist.GetRequest<List<ProcedureViewModel>>($"api/procedure/getprocedures?pharmacistid={APIPharmacist.Pharmacist.Id}");
return View();
}
[HttpPost]
public void CreateDescriptionProcedure(int service, string text)
{
if (APIPharmacist.Pharmacist == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
if (string.IsNullOrEmpty(text))
{
throw new Exception("Рекомендация не может быть пустой");
}
APIPharmacist.PostRequest("api/descriptionprocedure/createdescriptionprocedure", new
DescriptionProcedureBindingModel
{
Id = service,
});
Response.Redirect("Index");
}
[HttpGet]
public IActionResult UpdateDescriptionProcedure()
{
ViewBag.Services = APIPharmacist.GetRequest<List<ProcedureViewModel>>($"api/procedure/getprocedures?pharmacistid={APIPharmacist.Pharmacist.Id}");
ViewBag.Guidances = APIPharmacist.GetRequest<List<DescriptionProcedureViewModel>>($"api/descriptionprocedure/getdescriptionprocedurees?pharmacistid={APIPharmacist.Pharmacist.Id}");
return View();
}
[HttpPost]
public void UpdateDescriptionProcedure(int guidance, int service, string text)
{
if (APIPharmacist.Pharmacist == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
if (string.IsNullOrEmpty(text))
{
throw new Exception("Рекомендация не может быть пустой");
}
APIPharmacist.PostRequest("api/descriptionprocedure/updatedescriptionprocedure", new
DescriptionProcedureBindingModel
{
Id = guidance,
Description = text
});
Response.Redirect("Index");
}
[HttpGet]
public IActionResult DeleteDescriptionProcedure()
{
ViewBag.Guidances = APIPharmacist.GetRequest<List<DescriptionProcedureViewModel>>($"api/descriptionprocedure/getdescriptionprocedures?pharmacistid={APIPharmacist.Pharmacist.Id}");
return View();
}
[HttpPost]
public void DeleteDescriptionProcedure(int guidance)
{
if (APIPharmacist.Pharmacist == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIPharmacist.PostRequest("api/descriptionprocedure/deletedescriptionprocedure", new
DescriptionProcedureBindingModel
{
Id = guidance
});
Response.Redirect("Index");
}
[HttpGet]
public DescriptionProcedureViewModel GetDescriptionProcedure(int guidanceId)
{
if (APIPharmacist.Pharmacist == null)
{
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
}
var result = APIPharmacist.GetRequest<DescriptionProcedureViewModel>($"api/descriptionproceduree/getdescriptionproceduree?descriptionprocedureid={guidanceId}");
if (result == null)
{
return default;
}
return result;
}
public IActionResult IndexRecipes()
{
if (APIPharmacist.Pharmacist == null)
{
return Redirect("~/Home/Enter");
}
return Redirect("~/Home/Enter");
//View(APIPharmacist.GetRequest<List<RecipeViewModel>>($"api/animal/getrecipelist?PharmacistId={APIPharmacist.Pharmacist.Id}"));
}
public IActionResult IndexDiseases()
@ -61,18 +582,14 @@ View(APIPharmacist.GetRequest<List<RecipeViewModel>>($"api/animal/getrecipelist?
{
return Redirect("~/Home/Enter");
}
return
View(APIPharmacist.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?diseaseId={APIPharmacist.Pharmacist.Id}"));
return Redirect("~/Home/Privacy");
//View(APIPharmacist.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?diseaseId={APIPharmacist.Pharmacist.Id}"));
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
#region Вход и регистрация
@ -133,24 +650,24 @@ View(APIPharmacist.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?
APIPharmacist.Pharmacist.FIO = fio;
APIPharmacist.Pharmacist.Login = login;
APIPharmacist.Pharmacist.Password = password;
APIPharmacist.Pharmacist.PhoneNumber = telephone;
Response.Redirect("Index");
}
[HttpPost]
public void Register(string login, string email, string password, string fio, string telephone)
public void Register(string login, string password, string fio, string telephone)
{
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
{
throw new Exception("Введите логин, пароль и ФИО");
}
APIPharmacist.PostRequest("api/Pharmacist/register", new PharmacistBindingModel
APIPharmacist.PostRequest("api/pharmacist/register", new PharmacistBindingModel
{
FIO = fio,
Login = login,
Password = password,
PhoneNumber = telephone
});
@ -165,7 +682,7 @@ View(APIPharmacist.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?
{
throw new Exception("Введите логин и пароль");
}
APIPharmacist.Pharmacist = APIPharmacist.GetRequest<PharmacistViewModel>($"api/Pharmacist/login?login={login}&password={password}");
APIPharmacist.Pharmacist = APIPharmacist.GetRequest<PharmacistViewModel>($"api/pharmacist/login?login={login}&password={password}");
if (APIPharmacist.Pharmacist == null)
{
throw new Exception("Неверный логин/пароль");

View File

@ -7,6 +7,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.18">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NPOI" Version="2.7.0" />
</ItemGroup>

View File

@ -1,5 +1,5 @@
@{
ViewData["Title"] = "AddMedicineToRecipe";
ViewData["Title"] = "CreateDisease";
}
<head>
@ -8,17 +8,17 @@
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Название лекарства</label>
<label class="u-label u-text-custom-color-1 u-label-1">Название болезни</label>
<input type="text"
placeholder="Введите название лекарства"
name="medicineName"
placeholder="Введите название болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Начало</label>
<input type="text"
placeholder="Введите описание лекарства"
name="medicineName"
placeholder="Введите описание болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">

View File

@ -18,13 +18,20 @@
<input type="text" name="price" id="price" />
</div>
</div>
<div class="row">
<div class="col-4">Описание к процедуре:</div>
<div class="col-8">
<select id="descriptionofprocedure" name="descriptionofprocedure" class="form-control" asp-items="@(new SelectList(@ViewBag.Descriptions, "Id", "Description"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Лекарство:</div>
<div class="col-8">
<select name="medicines" class="form-control" multiple size="6" id="medicines">
@foreach (var medicine in ViewBag.Medicines)
{
<option value="@medicine.Id">@medicine.MedicineName</option>
<option value="@medicine.Id">@medicine.Name</option>
}
</select>
</div>
@ -36,4 +43,5 @@
btn-primary" />
</div>
</div>
</form>
</form>

View File

@ -8,7 +8,7 @@
<div class="row">
<div class="col-4">Лекарство:</div>
<div class="col-8">
<select id="medicine" name="medicine" class="form-control" asp-items="@(new SelectList(@ViewBag.Medicines, "Id", "MedicineName"))"></select>
<select id="medicine" name="medicine" class="form-control" asp-items="@(new SelectList(@ViewBag.Medicines, "Id", "Name"))"></select>
</div>
</div>
<div class="row">

View File

@ -8,7 +8,7 @@
<div class="row">
<div class="col-4">Процедура:</div>
<div class="col-8">
<select id="procedure" name="procedure" class="form-control" asp-items="@(new SelectList(@ViewBag.Procedures, "Id", "ProcedureName"))"></select>
<select id="procedure" name="procedure" class="form-control" asp-items="@(new SelectList(@ViewBag.Procedures, "Id", "Name"))"></select>
</div>
</div>
<div class="row">

View File

@ -18,9 +18,9 @@
return;
}
<p>
<a asp-action="UpdatePatient">Редактировать лекарство</a>
<a asp-action="DeletePatient">Удалить лекарство</a>
<a asp-action="ProcedurePatients">Связать лекарство и рецепт</a>
<a asp-action="UpdateMedicine">Редактировать лекарство</a>
<a asp-action="DeleteMedicine">Удалить лекарство</a>
<a asp-action="AddMedicineToRecipe">Связать лекарство и рецепт</a>
</p>
<p>
<a asp-action="CreateMedicine">Создать лекарство</a>
@ -35,7 +35,7 @@
Название
</th>
<th>
Страна производителя
Цена
</th>
</tr>
@ -52,7 +52,7 @@
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.CountryOrigin)
@Html.DisplayFor(modelItem => item.Price)
</td>
</tr>

View File

@ -1,10 +1,12 @@
@using HospitalContracts.ViewModels
@model List<ProcedureViewModel>
@{
ViewData["Title"] = "Procedurees";
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Процедуры</h1>
<h1 class="display-4">Услуги</h1>
</div>
<div class="text-center">
@{
@ -14,9 +16,9 @@
return;
}
<p>
<a asp-action="Createprocedure">Создать процедуру</a>
<a asp-action="Updateprocedure">Обновить процедуру</a>
<a asp-action="Deleteprocedure">Удалить процедуру</a>
<a asp-action="CreateProcedure">Создать услугу</a>
<a asp-action="UpdateProcedure">Обновить услугу</a>
<a asp-action="DeleteProcedure">Удалить услугу</a>
</p>
<table class="table">
<thead>
@ -27,7 +29,7 @@
<th>
Название
</th>
</tr>
</thead>
<tbody>
@ -42,7 +44,7 @@
@Html.DisplayFor(modelItem =>
item.Name)
</td>
</tr>
}
</tbody>

View File

@ -0,0 +1,65 @@
@using HospitalContracts.ViewModels;
@{
ViewData["Title"] = "MedicineRecipes";
}
<div class="text-center">
<h2 class="display-4">Связывание медикамента и животного</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Медикамент:</div>
<div class="col-8">
<select id="medicine" name="medicine" class="form-control" asp-items="@(new SelectList(@ViewBag.Medicines, "Id", "Name"))"></select>
</div>
</div>
<input style = "visibility: hidden" type="text" name="name" id="name" class="form-control" />
<input style = "visibility: hidden" type="text" id="price" name="price" class="form-control" />
<div class="row">
<div class="col-4">Животные:</div>
<div class="col-8">
<select name="animals" class="form-control" multiple size="5" id="animals">
@foreach (var recipe in ViewBag.Recipes)
{
<option value="@recipe.Id" data-name="@recipe.AnimalName">@recipe.AnimalName</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
</div>
</form>
@section Scripts
{
<script>
function check() {
var medicine = $('#medicine').val();
$("#recipes option:selected").removeAttr("selected");
if (medicine) {
$.ajax({
method: "GET",
url: "/Home/GetMedicine",
data: { medicineId: medicine },
success: function (result) {
console.log(result.item2);
$('#name').val(result.item1.Name);
$('#price').val(result.item1.price);
$.map(result.item2, function (n) {
console.log("#" + n);
$(`option[data-name=${n}]`).attr("selected", "selected")
});
}
});
};
}
check();
$('#medicine').on('change', function () {
check();
});
</script>
}

View File

@ -11,7 +11,7 @@
<div class="row">
<div class="col-4">Лекарство:</div>
<div class="col-8">
<select id="medicine" name="medicine" class="form-control" asp-items="@(new SelectList(@ViewBag.Medicines, "Id", "MedicineName"))"></select>
<select id="medicine" name="medicine" class="form-control" asp-items="@(new SelectList(@ViewBag.Medicines, "Id", "Name"))"></select>
</div>
</div>
<div class="row">

View File

@ -11,7 +11,7 @@
<div class="row">
<div class="col-4">Услуга:</div>
<div class="col-8">
<select id="service" name="procedure" class="form-control" asp-items="@(new SelectList(@ViewBag.procedures, "Id", "ProcedureName"))"></select>
<select id="service" name="procedure" class="form-control" asp-items="@(new SelectList(@ViewBag.procedures, "Id", "Name"))"></select>
</div>
</div>
<div class="row">
@ -28,7 +28,7 @@
<select name="medicines" class="form-control" multiple size="5" id="medicines">
@foreach (var medicine in ViewBag.Medicines)
{
<option value="@medicine.Id" data-name="@medicine.MedicineName">@medicine.MedicineName</option>
<option value="@medicine.Id" data-name="@medicine.Name">@medicine.Name</option>
}
</select>
</div>
@ -52,7 +52,7 @@
data: { procedureId: procedure },
success: function (result) {
console.log(result.item2);
$('#name').val(result.item1.procedureName);
$('#name').val(result.item1.Name);
$('#price').val(result.item1.price);
$.map(result.item2, function (n) {
console.log("#" + n);