From 6da19dcc84d20b9081bf55dbceda38a2e536683c Mon Sep 17 00:00:00 2001 From: Alenka Date: Sat, 25 May 2024 18:39:08 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=87=D0=B5=D0=BD=D1=8C=20=D1=81=D1=82?= =?UTF-8?q?=D1=80=D0=B0=D1=88=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/PatientLogic.cs | 2 +- .../BusinessLogics/PharmacistLogic.cs | 133 ++-- .../BusinessLogics/ProcedureLogic.cs | 4 +- .../BusinessLogics/ReportLogicDoctor.cs | 120 ++++ .../DescriptionProcedureBindingModel.cs | 1 - .../BindingModels/PharmacistBindingModel.cs | 5 +- .../BindingModels/ReportBindingModel.cs | 19 + .../IDoctorReportLogic.cs | 19 + .../SearchModels/DiseaseSearchModel.cs | 3 +- .../SearchModels/MedicineSearchModel.cs | 4 +- .../SearchModels/RecipeSearchModel.cs | 3 +- .../ReportPatientRecipeViewModel.cs | 14 + .../ViewModels/ReportPatientViewModel.cs | 16 + .../Implementss/PharmacistStorage.cs | 20 +- .../Models/DescriptionProcedure.cs | 2 - .../Implementss/DiseaseStorage.cs | 2 +- .../Implementss/RecipeStorage.cs | 2 +- .../Models/Medicine.cs | 1 + .../Models/Pharmacist.cs | 3 +- .../Models/Procedure.cs | 5 + .../Models/Recipe.cs | 1 + .../Controllers/HomeController.cs | 86 +-- .../Views/Home/CreatePatient.cshtml | 13 +- .../Views/Home/CreateRecipe.cshtml | 13 +- .../Views/Home/DeleteDisease.cshtml | 40 +- .../Views/Home/DeletePatient.cshtml | 2 +- .../Views/Home/DeleteRecipe.cshtml | 2 +- .../HospitalDoctorApp/Views/Home/Index.cshtml | 8 +- .../Views/Home/IndexDiseases.cshtml | 6 +- .../Views/Home/IndexRecipes.cshtml | 2 +- .../Views/Home/UpdateDisease.cshtml | 75 ++- .../Views/Home/UpdatePatient.cshtml | 15 +- .../Views/Home/UpdateRecipe.cshtml | 54 +- .../Controllers/HomeController.cs | 587 ++++++++++++++++-- .../HospitalPharmacistApp.csproj | 4 + .../Views/Home/AddMedicineToRecipe.cshtml | 12 +- .../Views/Home/CreateProcedure.cshtml | 12 +- .../Views/Home/DeleteMedicine.cshtml | 2 +- .../Views/Home/DeleteProcedure.cshtml | 2 +- .../PharmacistApp/Views/Home/Index.cshtml | 10 +- .../Views/Home/IndexProcedures.cshtml | 16 +- .../Views/Home/MedicineRecipes.cshtml | 65 ++ .../Views/Home/UpdateMedicine.cshtml | 2 +- .../Views/Home/UpdateProcedure.cshtml | 6 +- 44 files changed, 1141 insertions(+), 272 deletions(-) create mode 100644 Hospital/HospitalBusinessLogic/BusinessLogics/ReportLogicDoctor.cs create mode 100644 Hospital/HospitalContracts/BindingModels/ReportBindingModel.cs create mode 100644 Hospital/HospitalContracts/BusinessLogicContracts/IDoctorReportLogic.cs create mode 100644 Hospital/HospitalContracts/ViewModels/ReportPatientRecipeViewModel.cs create mode 100644 Hospital/HospitalContracts/ViewModels/ReportPatientViewModel.cs create mode 100644 Hospital/PharmacistApp/Views/Home/MedicineRecipes.cshtml diff --git a/Hospital/HospitalBusinessLogic/BusinessLogics/PatientLogic.cs b/Hospital/HospitalBusinessLogic/BusinessLogics/PatientLogic.cs index dbab8f7..0e60638 100644 --- a/Hospital/HospitalBusinessLogic/BusinessLogics/PatientLogic.cs +++ b/Hospital/HospitalBusinessLogic/BusinessLogics/PatientLogic.cs @@ -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, diff --git a/Hospital/HospitalBusinessLogic/BusinessLogics/PharmacistLogic.cs b/Hospital/HospitalBusinessLogic/BusinessLogics/PharmacistLogic.cs index d583b17..bc7f69b 100644 --- a/Hospital/HospitalBusinessLogic/BusinessLogics/PharmacistLogic.cs +++ b/Hospital/HospitalBusinessLogic/BusinessLogics/PharmacistLogic.cs @@ -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 logger, IPharmacistStorage - pharmacistStorage) + private readonly IPharmacistStorage _PharmacistStorage; + + public PharmacistLogic(ILogger logger, IPharmacistStorage PharmacistStorage) { _logger = logger; - _pharmacistStorage = pharmacistStorage; + _PharmacistStorage = PharmacistStorage; } - public List? 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? 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("Врач с таким именем уже есть"); } } } - } - diff --git a/Hospital/HospitalBusinessLogic/BusinessLogics/ProcedureLogic.cs b/Hospital/HospitalBusinessLogic/BusinessLogics/ProcedureLogic.cs index b0e296b..c5bc053 100644 --- a/Hospital/HospitalBusinessLogic/BusinessLogics/ProcedureLogic.cs +++ b/Hospital/HospitalBusinessLogic/BusinessLogics/ProcedureLogic.cs @@ -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("Процедура с таким названием уже есть"); } } } diff --git a/Hospital/HospitalBusinessLogic/BusinessLogics/ReportLogicDoctor.cs b/Hospital/HospitalBusinessLogic/BusinessLogics/ReportLogicDoctor.cs new file mode 100644 index 0000000..1a360d1 --- /dev/null +++ b/Hospital/HospitalBusinessLogic/BusinessLogics/ReportLogicDoctor.cs @@ -0,0 +1,120 @@ +using DocumentFormat.OpenXml.Office2010.ExcelAc; +using HospitalContracts.BindingModels; +using HospitalContracts.BusinessLogicContracts; +using HospitalContracts.SearchModels; +using HospitalContracts.StoragesContracts; +using HospitalContracts.ViewModels; +using HospitalDataModels.Models; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace HospitalBusinessLogic.BusinessLogics +{ + public class ReportLogicDoctor : IDoctorReportLogic + { + + private readonly IPatientStorage _patientStorage; + private readonly IMedicineStorage _medicineStorage; + private readonly IProcedureStorage _procedureStorage; + private readonly IRecipeStorage _recipeStorage; + private readonly IDiseaseStorage _diseaseStorage; + + public ReportLogicDoctor(IPatientStorage patientStorage, IMedicineStorage medicineStorage, IProcedureStorage procedureStorage, IRecipeStorage recipeStorage, IDiseaseStorage diseaseStorage) + { + + _patientStorage = patientStorage; + _medicineStorage = medicineStorage; + _procedureStorage = procedureStorage; + _recipeStorage = recipeStorage; + _diseaseStorage = diseaseStorage; + } + + //отчет по лекарствам и болезням у пациента за период + public List GetMedicineDiseases(ReportBindingModel model, PatientBindingModel patientModel) + { + var list = new List(); + var patients = _patientStorage.GetFilteredList(new PatientSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo, Id = patientModel.Id }); + + foreach (var patient in patients) + { + var purchase = _patientStorage.GetElement(new() { Id = patient.Id })!; + List diseaseList = new List(); + List medicineList = new List(); + foreach (var recipe in _recipeStorage.GetFilteredList(new RecipeSearchModel {PatientId = patient.Id})) + { + foreach (var medicine in _medicineStorage.GetFilteredList(new MedicineSearchModel { RecipeId = recipe.Id })) + { + medicineList.Add(new(medicine.Name)); + + + foreach (var disease in medicine.MedicineRecipes) + { + diseaseList.Add(disease.Value.Description); + } + } + } + var record = new ReportPatientViewModel + { + Id = purchase.Id, + FIO = patient.FIO, + + Diseases = diseaseList, + Medicines = medicineList + }; + list.Add(record); + } + return list; + } + + public List GetPatients() + { + var list = new List(); + var patients = _patientStorage.GetFullList(); + + foreach (var patient in patients) + { + var purchase = _patientStorage.GetElement(new() { Id = patient.Id })!; + List diseaseList = new List(); + List recipeList = new List(); + foreach (var recipe in _recipeStorage.GetFilteredList(new RecipeSearchModel { PatientId = patient.Id })) + { + recipeList.Add(recipe.IssueDate.ToString()); + foreach (var disease in _diseaseStorage.GetFilteredList(new DiseaseSearchModel { RecipeId = recipe.Id })) + { + diseaseList.Add(disease.Name); + } + } + var record = new ReportPatientRecipeViewModel + { + Diseases = diseaseList, + Recipes = recipeList + }; + list.Add(record); + } + return list; + } + + + + + public void SavePatientsToPdfFile(ReportBindingModel model) + { + throw new NotImplementedException(); + } + + public void SaveProcedureRecipesToExcelFile(ReportBindingModel model) + { + throw new NotImplementedException(); + } + + public void SaveProcedureRecipesToWordFile(ReportBindingModel model) + { + throw new NotImplementedException(); + } + } +} diff --git a/Hospital/HospitalContracts/BindingModels/DescriptionProcedureBindingModel.cs b/Hospital/HospitalContracts/BindingModels/DescriptionProcedureBindingModel.cs index 5034696..e347966 100644 --- a/Hospital/HospitalContracts/BindingModels/DescriptionProcedureBindingModel.cs +++ b/Hospital/HospitalContracts/BindingModels/DescriptionProcedureBindingModel.cs @@ -13,7 +13,6 @@ namespace HospitalContracts.BindingModels public string Description { get; set; } = string.Empty; public int PharmacistId { get; set; } - } } diff --git a/Hospital/HospitalContracts/BindingModels/PharmacistBindingModel.cs b/Hospital/HospitalContracts/BindingModels/PharmacistBindingModel.cs index cefab94..6a84dc3 100644 --- a/Hospital/HospitalContracts/BindingModels/PharmacistBindingModel.cs +++ b/Hospital/HospitalContracts/BindingModels/PharmacistBindingModel.cs @@ -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; } + } } diff --git a/Hospital/HospitalContracts/BindingModels/ReportBindingModel.cs b/Hospital/HospitalContracts/BindingModels/ReportBindingModel.cs new file mode 100644 index 0000000..9b54576 --- /dev/null +++ b/Hospital/HospitalContracts/BindingModels/ReportBindingModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HospitalContracts.BindingModels +{ + public class ReportBindingModel + { + public string FileName { get; set; } = string.Empty; + + public DateTime? DateFrom { get; set; } + + public DateTime? DateTo { get; set; } + + public int? PatientId { get; set; } + } +} diff --git a/Hospital/HospitalContracts/BusinessLogicContracts/IDoctorReportLogic.cs b/Hospital/HospitalContracts/BusinessLogicContracts/IDoctorReportLogic.cs new file mode 100644 index 0000000..0e2c1b0 --- /dev/null +++ b/Hospital/HospitalContracts/BusinessLogicContracts/IDoctorReportLogic.cs @@ -0,0 +1,19 @@ +using HospitalContracts.BindingModels; +using HospitalContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HospitalContracts.BusinessLogicContracts +{ + public interface IDoctorReportLogic + { + List GetPatients(); + List GetMedicineDiseases(ReportBindingModel model, PatientBindingModel patientModel); + void SaveProcedureRecipesToWordFile(ReportBindingModel model); + void SaveProcedureRecipesToExcelFile(ReportBindingModel model); + void SavePatientsToPdfFile(ReportBindingModel model); + } +} diff --git a/Hospital/HospitalContracts/SearchModels/DiseaseSearchModel.cs b/Hospital/HospitalContracts/SearchModels/DiseaseSearchModel.cs index 78a7be5..2391738 100644 --- a/Hospital/HospitalContracts/SearchModels/DiseaseSearchModel.cs +++ b/Hospital/HospitalContracts/SearchModels/DiseaseSearchModel.cs @@ -14,5 +14,6 @@ namespace HospitalContracts.SearchModels public string? Description { get; set; } public int? DoctorId { get; set; } - } + public int? RecipeId { get; set; } + } } diff --git a/Hospital/HospitalContracts/SearchModels/MedicineSearchModel.cs b/Hospital/HospitalContracts/SearchModels/MedicineSearchModel.cs index f32f3bd..592bacf 100644 --- a/Hospital/HospitalContracts/SearchModels/MedicineSearchModel.cs +++ b/Hospital/HospitalContracts/SearchModels/MedicineSearchModel.cs @@ -13,5 +13,7 @@ namespace HospitalContracts.SearchModels public string? CountryOrigin { get; set; } public double? Price { get; set; } public int? PharmacistId { get; set; } - } + + public int? RecipeId { get; set; } + } } diff --git a/Hospital/HospitalContracts/SearchModels/RecipeSearchModel.cs b/Hospital/HospitalContracts/SearchModels/RecipeSearchModel.cs index 70aaded..162c0a5 100644 --- a/Hospital/HospitalContracts/SearchModels/RecipeSearchModel.cs +++ b/Hospital/HospitalContracts/SearchModels/RecipeSearchModel.cs @@ -12,6 +12,7 @@ namespace HospitalContracts.SearchModels public int? DoctorId { get; set; } public int? MedicineId { get; set; } - DateTime IssueDate { get; } + public int? PatientId { get; set; } + DateTime IssueDate { get; } } } diff --git a/Hospital/HospitalContracts/ViewModels/ReportPatientRecipeViewModel.cs b/Hospital/HospitalContracts/ViewModels/ReportPatientRecipeViewModel.cs new file mode 100644 index 0000000..5cc8176 --- /dev/null +++ b/Hospital/HospitalContracts/ViewModels/ReportPatientRecipeViewModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HospitalContracts.ViewModels +{ + public class ReportPatientRecipeViewModel + { + public List Recipes { get; set; } = new(); + public List Diseases { get; set; } = new(); + } +} diff --git a/Hospital/HospitalContracts/ViewModels/ReportPatientViewModel.cs b/Hospital/HospitalContracts/ViewModels/ReportPatientViewModel.cs new file mode 100644 index 0000000..94ea181 --- /dev/null +++ b/Hospital/HospitalContracts/ViewModels/ReportPatientViewModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HospitalContracts.ViewModels +{ + public class ReportPatientViewModel + { + public int Id { get; set; } + public string FIO { get; set; } = string.Empty; + public List Medicines { get; set; } = new(); + public List Diseases { get; set; } = new(); + } +} diff --git a/Hospital/HospitalDataBaseImplement/Implementss/PharmacistStorage.cs b/Hospital/HospitalDataBaseImplement/Implementss/PharmacistStorage.cs index 497617a..45b0537 100644 --- a/Hospital/HospitalDataBaseImplement/Implementss/PharmacistStorage.cs +++ b/Hospital/HospitalDataBaseImplement/Implementss/PharmacistStorage.cs @@ -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 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; } diff --git a/Hospital/HospitalDataBaseImplement/Models/DescriptionProcedure.cs b/Hospital/HospitalDataBaseImplement/Models/DescriptionProcedure.cs index deab2d4..4edc583 100644 --- a/Hospital/HospitalDataBaseImplement/Models/DescriptionProcedure.cs +++ b/Hospital/HospitalDataBaseImplement/Models/DescriptionProcedure.cs @@ -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) diff --git a/Hospital/HospitalDatabaseImplement/Implementss/DiseaseStorage.cs b/Hospital/HospitalDatabaseImplement/Implementss/DiseaseStorage.cs index fb36a9a..12ee39b 100644 --- a/Hospital/HospitalDatabaseImplement/Implementss/DiseaseStorage.cs +++ b/Hospital/HospitalDatabaseImplement/Implementss/DiseaseStorage.cs @@ -31,7 +31,7 @@ namespace HospitalDatabaseImplement.Implementss public List 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) diff --git a/Hospital/HospitalDatabaseImplement/Implementss/RecipeStorage.cs b/Hospital/HospitalDatabaseImplement/Implementss/RecipeStorage.cs index 2b28925..080a502 100644 --- a/Hospital/HospitalDatabaseImplement/Implementss/RecipeStorage.cs +++ b/Hospital/HospitalDatabaseImplement/Implementss/RecipeStorage.cs @@ -26,7 +26,7 @@ namespace HospitalDatabaseImplement.Implementss public List GetFilteredList(RecipeSearchModel model) { using var context = new HospitalDatabase(); - if (!model.Id.HasValue) + if (model.Id.HasValue) { return context.Recipes .Include(x => x.Doctor) diff --git a/Hospital/HospitalDatabaseImplement/Models/Medicine.cs b/Hospital/HospitalDatabaseImplement/Models/Medicine.cs index c15384f..faa801f 100644 --- a/Hospital/HospitalDatabaseImplement/Models/Medicine.cs +++ b/Hospital/HospitalDatabaseImplement/Models/Medicine.cs @@ -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 { diff --git a/Hospital/HospitalDatabaseImplement/Models/Pharmacist.cs b/Hospital/HospitalDatabaseImplement/Models/Pharmacist.cs index 1cedb6a..1593cd8 100644 --- a/Hospital/HospitalDatabaseImplement/Models/Pharmacist.cs +++ b/Hospital/HospitalDatabaseImplement/Models/Pharmacist.cs @@ -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 }; } diff --git a/Hospital/HospitalDatabaseImplement/Models/Procedure.cs b/Hospital/HospitalDatabaseImplement/Models/Procedure.cs index 288b816..2538d50 100644 --- a/Hospital/HospitalDatabaseImplement/Models/Procedure.cs +++ b/Hospital/HospitalDatabaseImplement/Models/Procedure.cs @@ -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 { diff --git a/Hospital/HospitalDatabaseImplement/Models/Recipe.cs b/Hospital/HospitalDatabaseImplement/Models/Recipe.cs index 5a564d8..eadc189 100644 --- a/Hospital/HospitalDatabaseImplement/Models/Recipe.cs +++ b/Hospital/HospitalDatabaseImplement/Models/Recipe.cs @@ -75,6 +75,7 @@ namespace HospitalDatabaseImplement.Modelss { Id = Id, IssueDate = IssueDate, + Description = Description, RecipePatients = RecipePatients }; diff --git a/Hospital/HospitalDoctorApp/Controllers/HomeController.cs b/Hospital/HospitalDoctorApp/Controllers/HomeController.cs index 82a2e67..4d95edf 100644 --- a/Hospital/HospitalDoctorApp/Controllers/HomeController.cs +++ b/Hospital/HospitalDoctorApp/Controllers/HomeController.cs @@ -33,8 +33,7 @@ namespace HospitalDoctorApp.Controllers { return Redirect("~/Home/Enter"); } - return -View(APIClient.GetRequest>($"api/recipe/getrecipelist?doctorId={APIClient.Doctor.Id}")); + return View(APIClient.GetRequest>($"api/recipe/getrecipelist?doctorId={APIClient.Doctor.Id}")); } public IActionResult IndexDiseases() @@ -43,8 +42,7 @@ View(APIClient.GetRequest>($"api/recipe/getrecipelist?doct { return Redirect("~/Home/Enter"); } - return -View(APIClient.GetRequest>($"api/disease/getdiseases?diseaseId={APIClient.Doctor.Id}")); + return View(APIClient.GetRequest>($"api/disease/getdiseases?diseaseId={APIClient.Doctor.Id}")); } @@ -153,11 +151,12 @@ View(APIClient.GetRequest>($"api/disease/getdiseases?dise { return Redirect("~/Home/"); } + ViewBag.Procedures = APIClient.GetRequest>($"api/procedure/getprocedures"); return View(); } public IActionResult CreateRecipe() { - ViewBag.Recipes = APIClient.GetRequest>("api/disease/getdiseaselist"); + ViewBag.Diseases = APIClient.GetRequest>("api/disease/getdiseases"); if (APIClient.Doctor == null) { return Redirect("~/Home/"); @@ -170,31 +169,35 @@ View(APIClient.GetRequest>($"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 procedures) { if (APIClient.Doctor == null) { throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); } - if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(address)) - { - throw new Exception("Ошибка в введенных данных"); - } + Dictionary produresDict = new Dictionary(); + 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>($"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>($"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>($"api/disease/getdiseases?dise ViewBag.Recipes = APIClient.GetRequest>($"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>($"api/recipe/getrecipes?doctorid={APIClient.Doctor.Id}"); + + Response.Redirect("IndexRecipes"); + } + + + public IActionResult DeleteDisease() { if (APIClient.Doctor == null) { @@ -282,19 +302,6 @@ View(APIClient.GetRequest>($"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>($"api/disease/getdiseases?dise return Redirect("~/Home/Enter"); } ViewBag.Recipes = APIClient.GetRequest>($"api/recipe/getrecipelist?doctorid={APIClient.Doctor.Id}"); - return View(); + ViewBag.Diseases = APIClient.GetRequest>($"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>($"api/disease/getdiseases?dise { Id = recipe, Description = description, - IssueDate = issuedate - + IssueDate = date, + DiseaseId = disease + }); Response.Redirect("IndexRecipes"); } @@ -404,7 +414,7 @@ View(APIClient.GetRequest>($"api/disease/getdiseases?dise }); - Response.Redirect("IndexDisease"); + Response.Redirect("IndexDiseases"); } #endregion diff --git a/Hospital/HospitalDoctorApp/Views/Home/CreatePatient.cshtml b/Hospital/HospitalDoctorApp/Views/Home/CreatePatient.cshtml index ba379f3..6e1f128 100644 --- a/Hospital/HospitalDoctorApp/Views/Home/CreatePatient.cshtml +++ b/Hospital/HospitalDoctorApp/Views/Home/CreatePatient.cshtml @@ -18,7 +18,7 @@ +
+
Процедуры:
+
+ +
+
diff --git a/Hospital/HospitalDoctorApp/Views/Home/CreateRecipe.cshtml b/Hospital/HospitalDoctorApp/Views/Home/CreateRecipe.cshtml index 7da6825..cf116b4 100644 --- a/Hospital/HospitalDoctorApp/Views/Home/CreateRecipe.cshtml +++ b/Hospital/HospitalDoctorApp/Views/Home/CreateRecipe.cshtml @@ -18,11 +18,12 @@
-
-
Дата назначения:
-
- -
+
@@ -34,7 +35,7 @@ + diff --git a/Hospital/HospitalDoctorApp/Views/Home/UpdatePatient.cshtml b/Hospital/HospitalDoctorApp/Views/Home/UpdatePatient.cshtml index 347a176..834a2fe 100644 --- a/Hospital/HospitalDoctorApp/Views/Home/UpdatePatient.cshtml +++ b/Hospital/HospitalDoctorApp/Views/Home/UpdatePatient.cshtml @@ -11,22 +11,24 @@
Пациент:
- +
ФИО:
-
+
Дата рождения:
- +
- - +
+
Адрес:
+
+
@@ -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); } }); }; diff --git a/Hospital/HospitalDoctorApp/Views/Home/UpdateRecipe.cshtml b/Hospital/HospitalDoctorApp/Views/Home/UpdateRecipe.cshtml index 27c9076..452a43e 100644 --- a/Hospital/HospitalDoctorApp/Views/Home/UpdateRecipe.cshtml +++ b/Hospital/HospitalDoctorApp/Views/Home/UpdateRecipe.cshtml @@ -11,18 +11,28 @@
Рецепт:
- +
-
-
-
Название:
-
-
-
-
Описание:
-
-
+
+
Описание:
+
+ +
+
+
+
Болезнь:
+
+ +
+
+
@@ -31,3 +41,27 @@
+@section Scripts +{ + +} \ No newline at end of file diff --git a/Hospital/PharmacistApp/Controllers/HomeController.cs b/Hospital/PharmacistApp/Controllers/HomeController.cs index 4247d09..d7a1abb 100644 --- a/Hospital/PharmacistApp/Controllers/HomeController.cs +++ b/Hospital/PharmacistApp/Controllers/HomeController.cs @@ -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>($"api/visit/getpatients?PharmacistId={APIPharmacist.Pharmacist.Id}")); + return View(APIPharmacist.GetRequest>($"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>($"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>($"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>($"api/medicine/getmedicines?pharmacistid={APIPharmacist.Pharmacist.Id}"); + ViewBag.Animals = APIPharmacist.GetRequest>($"api/recipe/getrecipelist"); + return View(); + } + + + [HttpPost] + public void MedicineAnimals(int medicine, string name, string price, + List 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 a = new Dictionary(); + 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>? GetMedicine(int medicineId) + { + if (APIPharmacist.Pharmacist == null) + { + throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); + } + var result = APIPharmacist.GetRequest>>($"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($"api/animal/getanimal?animalid={animalId}"); + return result; + } + + public IActionResult IndexProcedures() { if (APIPharmacist.Pharmacist == null) { return Redirect("~/Home/Enter"); } return -View(APIPharmacist.GetRequest>($"api/animal/getrecipelist?PharmacistId={APIPharmacist.Pharmacist.Id}")); +View(APIPharmacist.GetRequest>($"api/procedure/getprocedures?pharmacistid={APIPharmacist.Pharmacist.Id}")); + + } + + + public IActionResult CreateProcedure() + { + if (APIPharmacist.Pharmacist == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Descriptions = APIPharmacist.GetRequest>($"api/descriptionprocedure/getdescriptionprocedurees?pharmacistid={APIPharmacist.Pharmacist.Id}"); + + ViewBag.Medicines = APIPharmacist.GetRequest>($"api/medicine/getmedicines"); + + return View(); + } + + + + [HttpPost] + public void CreateProcedure(string name, string price, List 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 a = new Dictionary(); + 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>($"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>($"api/procedure/getprocedures?pharmacistid={APIPharmacist.Pharmacist.Id}"); + ViewBag.Medicines = APIPharmacist.GetRequest>($"api/medicine/getmedicines"); + return View(); + } + + [HttpPost] + public void UpdateProcedure(int service, string name, string price, + List 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 a = new Dictionary(); + 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>? GetService(int serviceId) + { + if (APIPharmacist.Pharmacist == null) + { + throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì"); + } + var result = APIPharmacist.GetRequest>>($"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>($"api/descriptionprocedure/getdescriptionprocedurees?pharmacistid={APIPharmacist.Pharmacist.Id}"); + return +View(res); + + } + + [HttpGet] + public IActionResult CreateDescriptionProcedure() + { + ViewBag.Procedures = APIPharmacist.GetRequest>($"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>($"api/procedure/getprocedures?pharmacistid={APIPharmacist.Pharmacist.Id}"); + ViewBag.Guidances = APIPharmacist.GetRequest>($"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>($"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($"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>($"api/animal/getrecipelist?PharmacistId={APIPharmacist.Pharmacist.Id}")); } public IActionResult IndexDiseases() @@ -61,18 +582,14 @@ View(APIPharmacist.GetRequest>($"api/animal/getrecipelist? { return Redirect("~/Home/Enter"); } - return -View(APIPharmacist.GetRequest>($"api/disease/getdiseases?diseaseId={APIPharmacist.Pharmacist.Id}")); + return Redirect("~/Home/Privacy"); + //View(APIPharmacist.GetRequest>($"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>($"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>($"api/disease/getdiseases? { throw new Exception("Введите логин и пароль"); } - APIPharmacist.Pharmacist = APIPharmacist.GetRequest($"api/Pharmacist/login?login={login}&password={password}"); + APIPharmacist.Pharmacist = APIPharmacist.GetRequest($"api/pharmacist/login?login={login}&password={password}"); if (APIPharmacist.Pharmacist == null) { throw new Exception("Неверный логин/пароль"); diff --git a/Hospital/PharmacistApp/HospitalPharmacistApp.csproj b/Hospital/PharmacistApp/HospitalPharmacistApp.csproj index e43bf8c..f51e90d 100644 --- a/Hospital/PharmacistApp/HospitalPharmacistApp.csproj +++ b/Hospital/PharmacistApp/HospitalPharmacistApp.csproj @@ -7,6 +7,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/Hospital/PharmacistApp/Views/Home/AddMedicineToRecipe.cshtml b/Hospital/PharmacistApp/Views/Home/AddMedicineToRecipe.cshtml index 7c213b0..59ea11d 100644 --- a/Hospital/PharmacistApp/Views/Home/AddMedicineToRecipe.cshtml +++ b/Hospital/PharmacistApp/Views/Home/AddMedicineToRecipe.cshtml @@ -1,5 +1,5 @@ @{ - ViewData["Title"] = "AddMedicineToRecipe"; + ViewData["Title"] = "CreateDisease"; } @@ -8,17 +8,17 @@
- +
diff --git a/Hospital/PharmacistApp/Views/Home/CreateProcedure.cshtml b/Hospital/PharmacistApp/Views/Home/CreateProcedure.cshtml index 3a4dab8..c56c850 100644 --- a/Hospital/PharmacistApp/Views/Home/CreateProcedure.cshtml +++ b/Hospital/PharmacistApp/Views/Home/CreateProcedure.cshtml @@ -18,13 +18,20 @@
+
+
Описание к процедуре:
+
+ +
+ +
Лекарство:
@@ -36,4 +43,5 @@ btn-primary" />
- \ No newline at end of file + + diff --git a/Hospital/PharmacistApp/Views/Home/DeleteMedicine.cshtml b/Hospital/PharmacistApp/Views/Home/DeleteMedicine.cshtml index a7281f0..1851d12 100644 --- a/Hospital/PharmacistApp/Views/Home/DeleteMedicine.cshtml +++ b/Hospital/PharmacistApp/Views/Home/DeleteMedicine.cshtml @@ -8,7 +8,7 @@
Лекарство:
- +
diff --git a/Hospital/PharmacistApp/Views/Home/DeleteProcedure.cshtml b/Hospital/PharmacistApp/Views/Home/DeleteProcedure.cshtml index 6d42eb3..a1c9bbe 100644 --- a/Hospital/PharmacistApp/Views/Home/DeleteProcedure.cshtml +++ b/Hospital/PharmacistApp/Views/Home/DeleteProcedure.cshtml @@ -8,7 +8,7 @@
Процедура:
- +
diff --git a/Hospital/PharmacistApp/Views/Home/Index.cshtml b/Hospital/PharmacistApp/Views/Home/Index.cshtml index b590cb5..2d9fc07 100644 --- a/Hospital/PharmacistApp/Views/Home/Index.cshtml +++ b/Hospital/PharmacistApp/Views/Home/Index.cshtml @@ -18,9 +18,9 @@ return; }

- Редактировать лекарство - Удалить лекарство - Связать лекарство и рецепт + Редактировать лекарство + Удалить лекарство + Связать лекарство и рецепт

Создать лекарство @@ -35,7 +35,7 @@ Название - Страна производителя + Цена @@ -52,7 +52,7 @@ @Html.DisplayFor(modelItem => item.Name) - @Html.DisplayFor(modelItem => item.CountryOrigin) + @Html.DisplayFor(modelItem => item.Price) diff --git a/Hospital/PharmacistApp/Views/Home/IndexProcedures.cshtml b/Hospital/PharmacistApp/Views/Home/IndexProcedures.cshtml index 1db819a..993634f 100644 --- a/Hospital/PharmacistApp/Views/Home/IndexProcedures.cshtml +++ b/Hospital/PharmacistApp/Views/Home/IndexProcedures.cshtml @@ -1,10 +1,12 @@ @using HospitalContracts.ViewModels + @model List + @{ - ViewData["Title"] = "Procedurees"; + ViewData["Title"] = "Home Page"; }

-

Процедуры

+

Услуги

@{ @@ -14,9 +16,9 @@ return; }

- Создать процедуру - Обновить процедуру - Удалить процедуру + Создать услугу + Обновить услугу + Удалить услугу

@@ -27,7 +29,7 @@ - + @@ -42,7 +44,7 @@ @Html.DisplayFor(modelItem => item.Name) - + } diff --git a/Hospital/PharmacistApp/Views/Home/MedicineRecipes.cshtml b/Hospital/PharmacistApp/Views/Home/MedicineRecipes.cshtml new file mode 100644 index 0000000..ca98b54 --- /dev/null +++ b/Hospital/PharmacistApp/Views/Home/MedicineRecipes.cshtml @@ -0,0 +1,65 @@ +@using HospitalContracts.ViewModels; + +@{ + ViewData["Title"] = "MedicineRecipes"; +} + +
+

Связывание медикамента и животного

+
+ +
+
Медикамент:
+
+ +
+
+ + +
+
Животные:
+
+ +
+
+
+
+
+
+ + +@section Scripts +{ + +} \ No newline at end of file diff --git a/Hospital/PharmacistApp/Views/Home/UpdateMedicine.cshtml b/Hospital/PharmacistApp/Views/Home/UpdateMedicine.cshtml index 2579da7..bd3708c 100644 --- a/Hospital/PharmacistApp/Views/Home/UpdateMedicine.cshtml +++ b/Hospital/PharmacistApp/Views/Home/UpdateMedicine.cshtml @@ -11,7 +11,7 @@
Лекарство:
- +
diff --git a/Hospital/PharmacistApp/Views/Home/UpdateProcedure.cshtml b/Hospital/PharmacistApp/Views/Home/UpdateProcedure.cshtml index b9124cb..73b0d2c 100644 --- a/Hospital/PharmacistApp/Views/Home/UpdateProcedure.cshtml +++ b/Hospital/PharmacistApp/Views/Home/UpdateProcedure.cshtml @@ -11,7 +11,7 @@
Услуга:
- +
@@ -28,7 +28,7 @@
@@ -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);
Название