Compare commits

..

46 Commits

Author SHA1 Message Date
c9e51c422a решение конфликтов в приложении фармацевта 2024-05-01 07:12:06 +04:00
2df3afc00e добавление контроллеров в рест апи приложение для рабоника 2024-05-01 07:10:07 +04:00
Alenka
d0cc63abfe почти финиш 2024-05-01 00:03:20 +04:00
Alenka
5c8b768dc1 до сдачи 1,5 часа 2024-04-30 16:23:51 +04:00
Alenka
050762b81d продолжаю делать приложение 2024-04-30 16:20:04 +04:00
18295f78b9 Merge branch 'develop' of https://git.is.ulstu.ru/ValAnn/PIbd_23_Panina_A._D._Valova_A._D._Hospital into develop 2024-04-30 16:17:11 +04:00
cf75520b70 продолжение изменнеий моделей, бд и приложений и контроллеров 2024-04-30 16:16:49 +04:00
52f5e5a1e3 изменение моделей, бд и создание приложения для работника 2024-04-30 16:16:18 +04:00
Alenka
c0d0b68892 еще раз фиксики 2024-04-29 23:30:02 +04:00
Alenka
38196534b9 кто такие фиксики 2024-04-29 23:27:08 +04:00
Alenka
0054d6550a rest api что ли 2024-04-29 23:15:01 +04:00
549fb1ec23 начало создания клиентского приложения для доктора 2024-04-29 22:10:04 +04:00
30ea05901a измененные миграции 2024-04-29 20:45:10 +04:00
c43bf6c66d медицине сторадж, любиоме 2024-04-29 16:33:02 +04:00
01996f74f1 решение конфликтов 2024-04-29 16:31:39 +04:00
0b87bc8287 сторадж медицине 2024-04-29 16:24:35 +04:00
Alenka
df2127107f Пересобираем БД, ура 2024-04-29 16:13:40 +04:00
9a10ad410d измененн фофрмат даных у пациента 2024-04-29 15:11:05 +04:00
ced335c941 добавлены таблицы бд работника 2024-04-29 13:37:57 +04:00
5e0f6fd0be модели для базы данных работника 2024-04-29 12:31:20 +04:00
f2041b026e убирание цены, решение конфликтов 2024-04-29 12:30:53 +04:00
b65e364788 добавлены бизнес-логика для сущностей работника 2024-04-29 11:20:14 +04:00
Alenka
b5c19360c8 Ничего не работает, начала делать app 2024-04-28 23:27:27 +04:00
Alenka
e12f96bb3e Начала делать БД 2024-04-27 23:17:05 +04:00
Alenka
9e8c7b46d2 исправления 2024-04-27 22:21:37 +04:00
575e573a38 сделаны однонаправленные связи + добавлены контракты работника 2024-04-27 21:51:26 +04:00
Alenka
6654a1b627 Доделала бизнес логику 2024-04-27 17:38:40 +04:00
Alenka
910e0d374e бизнесс логика, даже работает 2024-04-27 16:55:11 +04:00
Alenka
8745ef65a8 Кажется слой контрактов done 2024-04-27 16:37:42 +04:00
Alenka
7b81211711 Начало storage 2024-04-27 16:10:51 +04:00
Alenka
00ed5959f0 Начала бизнесс логику 2024-04-27 15:40:02 +04:00
Alenka
c5c0273831 проверка коммита 2024-04-27 13:10:12 +04:00
e4dd335a12 добавление бизнес-логики и переименования 2024-04-27 12:59:42 +04:00
Alenka
cc1edf7a7d Продолжаю ломать гит 2024-04-27 00:09:51 +04:00
Alenka
086679ff89 ломаю гит 2024-04-27 00:06:24 +04:00
Alenka
139333ed95 модельки 2024-04-26 23:24:46 +04:00
Alenka
17756e6991 Пусть будет 2024-04-25 19:09:14 +04:00
Alenka
da083000b1 Что то типо часть БД 2024-04-25 19:05:49 +04:00
Alenka
1ea63f1588 ViewModel 2024-04-24 12:49:55 +04:00
Alenka
c0058315ee Допилила модели 2024-04-23 23:06:04 +04:00
Alenka
7629dc561b Создала фиксики 2024-04-22 14:31:35 +04:00
aab75401ba view of recipe 2024-04-13 00:00:24 +04:00
181c9a1181 view of procedure 2024-04-12 23:59:18 +04:00
cb3b32509c Implement new feature 2024-04-12 23:54:59 +04:00
e9185fa7dc создание общих проектов 2024-04-12 21:57:42 +04:00
2de477b1cc добавление моделей 2024-04-12 21:43:20 +04:00
288 changed files with 157672 additions and 0 deletions

View File

@ -5,6 +5,20 @@ VisualStudioVersion = 17.9.34723.18
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalView", "Hospital\HospitalView.csproj", "{C50859B7-7F2C-4308-B9F7-86119A83E155}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalDataModels", "HospitalDataModels\HospitalDataModels.csproj", "{3CBB9321-2FA0-453A-970F-D8DCD6D4C654}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalContracts", "HospitalContracts\HospitalContracts.csproj", "{78516D88-C507-42D8-B534-89BBB1D8E136}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalBusinessLogic", "HospitalBusinessLogic\HospitalBusinessLogic.csproj", "{FA80C91B-0CE2-48A1-9B9A-EB443F3ABC44}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalDatabaseImplement", "HospitalDatabaseImplement\HospitalDatabaseImplement.csproj", "{651AD7CE-7821-4BDF-9FA4-4F61DC5CF5C4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PharmacistApp", "PharmacistApp\PharmacistApp.csproj", "{5CE4060B-0791-4F09-A52D-EF3EFF4EBF03}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HospitalRestApi", "HospitalRestApi\HospitalRestApi.csproj", "{C524A697-427E-40BD-955C-334255D958B7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HospitalDoctorApp", "HospitalDoctorApp\HospitalDoctorApp.csproj", "{0E3C0346-E31B-401F-8047-CE157D984F33}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -15,6 +29,34 @@ Global
{C50859B7-7F2C-4308-B9F7-86119A83E155}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C50859B7-7F2C-4308-B9F7-86119A83E155}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C50859B7-7F2C-4308-B9F7-86119A83E155}.Release|Any CPU.Build.0 = Release|Any CPU
{3CBB9321-2FA0-453A-970F-D8DCD6D4C654}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3CBB9321-2FA0-453A-970F-D8DCD6D4C654}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3CBB9321-2FA0-453A-970F-D8DCD6D4C654}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3CBB9321-2FA0-453A-970F-D8DCD6D4C654}.Release|Any CPU.Build.0 = Release|Any CPU
{78516D88-C507-42D8-B534-89BBB1D8E136}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78516D88-C507-42D8-B534-89BBB1D8E136}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78516D88-C507-42D8-B534-89BBB1D8E136}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78516D88-C507-42D8-B534-89BBB1D8E136}.Release|Any CPU.Build.0 = Release|Any CPU
{FA80C91B-0CE2-48A1-9B9A-EB443F3ABC44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FA80C91B-0CE2-48A1-9B9A-EB443F3ABC44}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA80C91B-0CE2-48A1-9B9A-EB443F3ABC44}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA80C91B-0CE2-48A1-9B9A-EB443F3ABC44}.Release|Any CPU.Build.0 = Release|Any CPU
{651AD7CE-7821-4BDF-9FA4-4F61DC5CF5C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{651AD7CE-7821-4BDF-9FA4-4F61DC5CF5C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{651AD7CE-7821-4BDF-9FA4-4F61DC5CF5C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{651AD7CE-7821-4BDF-9FA4-4F61DC5CF5C4}.Release|Any CPU.Build.0 = Release|Any CPU
{5CE4060B-0791-4F09-A52D-EF3EFF4EBF03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5CE4060B-0791-4F09-A52D-EF3EFF4EBF03}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5CE4060B-0791-4F09-A52D-EF3EFF4EBF03}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5CE4060B-0791-4F09-A52D-EF3EFF4EBF03}.Release|Any CPU.Build.0 = Release|Any CPU
{0E3C0346-E31B-401F-8047-CE157D984F33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0E3C0346-E31B-401F-8047-CE157D984F33}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0E3C0346-E31B-401F-8047-CE157D984F33}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0E3C0346-E31B-401F-8047-CE157D984F33}.Release|Any CPU.Build.0 = Release|Any CPU
{C524A697-427E-40BD-955C-334255D958B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C524A697-427E-40BD-955C-334255D958B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C524A697-427E-40BD-955C-334255D958B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C524A697-427E-40BD-955C-334255D958B7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -8,4 +8,18 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.17">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HospitalBusinessLogic\HospitalBusinessLogic.csproj" />
<ProjectReference Include="..\HospitalContracts\HospitalContracts.csproj" />
<ProjectReference Include="..\HospitalDatabaseImplement\HospitalDatabaseImplement.csproj" />
<ProjectReference Include="..\HospitalDataModels\HospitalDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,12 @@
{
"profiles": {
"HospitalView": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:51159;http://localhost:51164"
}
}
}

View File

@ -0,0 +1,110 @@
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 DescriptionProcedureLogic : IDescriptionProcedureLogic
{
private readonly ILogger _logger;
private readonly IDescriptionProcedureStorage _guidanceStorage;
public DescriptionProcedureLogic(ILogger<DescriptionProcedureLogic> logger, IDescriptionProcedureStorage guidanceStorage)
{
_logger = logger;
_guidanceStorage = guidanceStorage;
}
public DescriptionProcedureViewModel? ReadElement(DescriptionProcedureSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
var element = _guidanceStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<DescriptionProcedureViewModel>? ReadList(DescriptionProcedureSearchModel? model)
{
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
var list = model == null ? _guidanceStorage.GetFullList() :
_guidanceStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public bool Create(DescriptionProcedureBindingModel model)
{
CheckModel(model);
if (_guidanceStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(DescriptionProcedureBindingModel model)
{
CheckModel(model);
if (_guidanceStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(DescriptionProcedureBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_guidanceStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(DescriptionProcedureBindingModel model, bool withParams =
true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Description))
{
throw new ArgumentNullException("Нет текста рекомендации",
nameof(model.Description));
}
_logger.LogInformation("Guidance. Text:{Text}.", model.Description);
}
}
}

View File

@ -0,0 +1,115 @@
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;
namespace HospitalBusinessLogic.BusinessLogics
{
public class DiseaseLogic : IDiseaseLogic
{
private readonly ILogger _logger;
private readonly IDiseaseStorage _diseaseStorage;
public DiseaseLogic(ILogger<DiseaseLogic> logger, IDiseaseStorage diseaseStorage)
{
_logger = logger;
_diseaseStorage = diseaseStorage;
}
public bool Create(DiseaseBindingModel model)
{
CheckModel(model);
if (_diseaseStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(DiseaseBindingModel model)
{
CheckModel(model);
if (_diseaseStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(DiseaseBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_diseaseStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public DiseaseViewModel? ReadElement(DiseaseSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Name:{Name}. Id:{ Id}", model.Name, model.Id);
var element = _diseaseStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<DiseaseViewModel>? ReadList(DiseaseSearchModel? model)
{
_logger.LogInformation("ReadList. DiseaseId:{Id}", model?.Id);
var list = model == null ? _diseaseStorage.GetFullList() : _diseaseStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
private void CheckModel(DiseaseBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentNullException("Нет названия болезни", nameof(model.Name));
}
_logger.LogInformation("Disease. Name:{Name}. Description:{Description}. DoctorId:{DoctorId}. Id:{ Id}", model.Name, model.Description, model.DoctorId, model.Id);
var element = _diseaseStorage.GetElement(new DiseaseSearchModel
{
Name = model.Name,
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Болезнь с такими данными уже есть");
}
}
}
}

View File

@ -0,0 +1,124 @@
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;
namespace HospitalBusinessLogic.BusinessLogics
{
public class DoctorLogic : IDoctorLogic
{
private readonly ILogger _logger;
private readonly IDoctorStorage _doctorStorage;
public DoctorLogic(ILogger<DoctorLogic> logger, IDoctorStorage doctorStorage)
{
_logger = logger;
_doctorStorage = doctorStorage;
}
public bool Create(DoctorBindingModel model)
{
CheckModel(model);
if (_doctorStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(DoctorBindingModel model)
{
CheckModel(model);
if (_doctorStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(DoctorBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_doctorStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public DoctorViewModel? ReadElement(DoctorSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Login:{Login}. PhoneNumber:{PhoneNumber}. Id:{ Id}", model.Login, model.PhoneNumber, model.Id);
var element = _doctorStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<DoctorViewModel>? ReadList(DoctorSearchModel? model)
{
_logger.LogInformation("ReadList. DoctorId:{Id}", model?.Id);
var list = model == null ? _doctorStorage.GetFullList() : _doctorStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
private void CheckModel(DoctorBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(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));
}
_logger.LogInformation("Doctor. Login:{Login}. PhoneNumber:{PhoneNumber}. Password:{Password}. Id:{ Id}", model.Login, model.PhoneNumber, model.Password, model.Id);
var element = _doctorStorage.GetElement(new DoctorSearchModel
{
Login = model.Login,
Password = model.Password
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Врач с таким именем уже есть");
}
}
}
}

View File

@ -0,0 +1,120 @@
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 MedicineLogic : IMedicineLogic
{
private readonly ILogger _logger;
private readonly IMedicineStorage _medicineStorage;
public MedicineLogic(ILogger<MedicineLogic> logger, IMedicineStorage iceCreamStorage)
{
_logger = logger;
_medicineStorage = iceCreamStorage;
}
public List<MedicineViewModel>? ReadList(MedicineSearchModel? model)
{
_logger.LogInformation("ReadList. MedicineName:{MedicineName}. Id:{ Id}", model?.Name, model?.Id);
var list = model == null ? _medicineStorage.GetFullList() :
_medicineStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public MedicineViewModel? ReadElement(MedicineSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. MedicineName:{MedicineName}.Id:{ Id}", model.Name, model.Id);
var element = _medicineStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(MedicineBindingModel model)
{
CheckModel(model);
if (_medicineStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(MedicineBindingModel model)
{
CheckModel(model);
if (_medicineStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(MedicineBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_medicineStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(MedicineBindingModel model, bool withParams =
true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentNullException("Нет названия медикамента",
nameof(model.Name));
}
if (model.Price <= 0)
{
throw new ArgumentNullException("Цена медикамента должна быть больше 0", nameof(model.Price));
}
_logger.LogInformation("Medicine. Medicine:{MedicineName}. Price:{ Price }. Id: { Id}", model.Name, model.Price, model.Id);
var element = _medicineStorage.GetElement(new MedicineSearchModel
{
Name = model.Name
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Медикамент с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,120 @@
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;
namespace HospitalBusinessLogic.BusinessLogics
{
public class PatientLogic : IPatientLogic
{
private readonly ILogger _logger;
private readonly IPatientStorage _patientStorage;
public PatientLogic(ILogger<PatientLogic> logger, IPatientStorage patientStorage)
{
_logger = logger;
_patientStorage = patientStorage;
}
public bool Create(PatientBindingModel model)
{
CheckModel(model);
if (_patientStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(PatientBindingModel model)
{
CheckModel(model);
if (_patientStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(PatientBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_patientStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public PatientViewModel? ReadElement(PatientSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. FIO:{FIO}. Id:{ Id}", model.FIO, model.Id);
var element = _patientStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<PatientViewModel>? ReadList(PatientSearchModel? model)
{
_logger.LogInformation("ReadList. PatientId:{Id}", model?.Id);
var list = model == null ? _patientStorage.GetFullList() : _patientStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
private void CheckModel(PatientBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.FIO))
{
throw new ArgumentNullException("Нет FIO пациента", nameof(model.FIO));
}
/*if (model.BirthDate < DateTime.Now.)
{
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);
var element = _patientStorage.GetElement(new PatientSearchModel
{
FIO = model.FIO,
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Пациент с такими данными уже есть");
}
}
}
}

View File

@ -0,0 +1,127 @@
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)
{
_logger = logger;
_pharmacistStorage = pharmacistStorage;
}
public List<PharmacistViewModel>? ReadList(PharmacistSearchModel? model)
{
_logger.LogInformation("ReadList. FIO:{FIO}. Id:{ Id}", model?.FIO, model?.Id);
var list = model == null ? _pharmacistStorage.GetFullList() :
_pharmacistStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
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);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(PharmacistBindingModel model)
{
CheckModel(model);
if (_pharmacistStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
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;
}
private void CheckModel(PharmacistBindingModel model, bool withParams =
true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.FIO))
{
throw new ArgumentNullException("Нет ФИО клиента",
nameof(model.FIO));
}
if (string.IsNullOrEmpty(model.Login))
{
throw new ArgumentNullException("Нет Email клиента",
nameof(model.Login));
}
if (string.IsNullOrEmpty(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
{
Login = model.Login,
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Клиент с таким логином уже есть");
}
}
}
}

View File

@ -0,0 +1,120 @@
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 ProcedureLogic : IProcedureLogic
{
private readonly ILogger _logger;
private readonly IProcedureStorage _serviceStorage;
public ProcedureLogic(ILogger<ProcedureLogic> logger, IProcedureStorage serviceStorage)
{
_logger = logger;
_serviceStorage = serviceStorage;
}
public List<ProcedureViewModel>? ReadList(ProcedureSearchModel? model)
{
_logger.LogInformation("ReadList. ServiceName:{ServiceName}. Id:{ Id}", model?.Name, model?.Id);
var list = model == null ? _serviceStorage.GetFullList() :
_serviceStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public ProcedureViewModel? ReadElement(ProcedureSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ServiceName:{ServiceName}.Id:{ Id}", model.Name, model.Id);
var element = _serviceStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(ProcedureBindingModel model)
{
CheckModel(model);
if (_serviceStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(ProcedureBindingModel model)
{
CheckModel(model);
if (_serviceStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(ProcedureBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_serviceStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(ProcedureBindingModel model, bool withParams =
true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentNullException("Нет названия услуги",
nameof(model.Name));
}
//if (model.Price <= 0)
{
// throw new ArgumentNullException("Цена мороженного услуги быть больше 0", nameof(model.Price));
}
_logger.LogInformation("Service. ServiceName:{ServiceName}. Id: { Id}", model.Name, model.Id);
var element = _serviceStorage.GetElement(new ProcedureSearchModel
{
Name = model.Name
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Услуга с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,115 @@
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;
namespace HospitalBusinessLogic.BusinessLogics
{
public class RecipeLogic : IRecipeLogic
{
private readonly ILogger _logger;
private readonly IRecipeStorage _recipeStorage;
public RecipeLogic(ILogger<RecipeLogic> logger, IRecipeStorage recipeStorage)
{
_logger = logger;
_recipeStorage = recipeStorage;
}
public bool Create(RecipeBindingModel model)
{
CheckModel(model);
if (_recipeStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(RecipeBindingModel model)
{
CheckModel(model);
if (_recipeStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(RecipeBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_recipeStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public RecipeViewModel? ReadElement(RecipeSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
var element = _recipeStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<RecipeViewModel>? ReadList(RecipeSearchModel? model)
{
_logger.LogInformation("ReadList. RecipeId:{Id}", model?.Id);
var list = model == null ? _recipeStorage.GetFullList() : _recipeStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
private void CheckModel(RecipeBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
/*if (model.RecipeMedicines == null || model.RecipeMedicines.Count == 0)
{
throw new ArgumentNullException("Нет лекарств в рецепте", nameof(model.RecipeMedicines));
}TODO*/
_logger.LogInformation("Recipe. Id:{ Id}. DiseaseId:{DiseaseId}. DoctorId:{DoctorId}", model.Id, model.DiseaseId, model.DoctorId);
var element = _recipeStorage.GetElement(new RecipeSearchModel
{
Id = model.Id,
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Пациент с такими данными уже есть");
}
}
}
}

View File

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HospitalContracts\HospitalContracts.csproj" />
<ProjectReference Include="..\HospitalDataModels\HospitalDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,12 @@
{
"profiles": {
"HospitalBusinessLogic": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:51157;http://localhost:51163"
}
}
}

View File

@ -0,0 +1,19 @@
using HospitalDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BindingModels
{
public class DescriptionProcedureBindingModel : IDescriptionProcedureModel
{
public int Id { get; set; }
public string Description { get; set; } = string.Empty;
public int PharmacistId { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using HospitalDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BindingModels
{
public class DiseaseBindingModel : IDiseaseModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public int DoctorId { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalDataModels.Models;
namespace HospitalContracts.BindingModels
{
public class DoctorBindingModel : IDoctorModel
{
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 MailAddress { get; set; } = string.Empty;
public string PhoneNumber { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalDataModels.Models;
namespace HospitalContracts.BindingModels
{
public class MedicineBindingModel : IMedicineModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string CountryOrigin { get; set; } = string.Empty;
public double Price { get; set; }
public int PharmacistId { get; set; }
public Dictionary<int, IRecipeModel> MedicineRecipes { get; set; } = new();
}
}

View File

@ -0,0 +1,25 @@
using HospitalDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BindingModels
{
public class PatientBindingModel : IPatientModel
{
public int Id { get; set; }
public string FIO { get; set; } = string.Empty;
public string Address { get; set; } = string.Empty;
public DateTime BirthDate { get; set; }
public int DoctorId { get; set; }
public Dictionary<int, IProcedureModel> PatientProcedures { get; set; } = new();
}
}

View File

@ -0,0 +1,19 @@
using HospitalDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BindingModels
{
public class PharmacistBindingModel : IPharmacistModel
{
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

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalDataModels.Models;
namespace HospitalContracts.BindingModels
{
public class ProcedureBindingModel : IProcedureModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public DateTime Date { get; set; }
public int DescriptionProcedureId { get; set; }
public int PharmacistId { get; set; }
public Dictionary<int, IMedicineModel> ProcedureMedicines { get; set; } = new();
}
}

View File

@ -0,0 +1,23 @@
using HospitalDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BindingModels
{
public class RecipeBindingModel : IRecipeModel
{
public int Id { get; set; }
public string Description { get; set; } = string.Empty;
public DateTime IssueDate { get; set; } = DateTime.Now;
public int DiseaseId { get; set; }
public int DoctorId { get; set; }
public Dictionary<int, IPatientModel> RecipePatients { get; set; } = new();
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
namespace HospitalContracts.BusinessLogicContracts
{
public interface IDescriptionProcedureLogic
{
List<DescriptionProcedureViewModel>? ReadList(DescriptionProcedureSearchModel? model);
DescriptionProcedureViewModel? ReadElement(DescriptionProcedureSearchModel model);
bool Create(DescriptionProcedureBindingModel model);
bool Update(DescriptionProcedureBindingModel model);
bool Delete(DescriptionProcedureBindingModel model);
}
}

View File

@ -0,0 +1,24 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BusinessLogicContracts
{
public interface IDiseaseLogic
{
List<DiseaseViewModel>? ReadList(DiseaseSearchModel? model);
DiseaseViewModel? ReadElement(DiseaseSearchModel model);
bool Create(DiseaseBindingModel model);
bool Update(DiseaseBindingModel model);
bool Delete(DiseaseBindingModel model);
}
}

View File

@ -0,0 +1,24 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BusinessLogicContracts
{
public interface IDoctorLogic
{
List<DoctorViewModel>? ReadList(DoctorSearchModel? model);
DoctorViewModel? ReadElement(DoctorSearchModel model);
bool Create(DoctorBindingModel model);
bool Update(DoctorBindingModel model);
bool Delete(DoctorBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BusinessLogicContracts
{
public interface IMedicineLogic
{
List<MedicineViewModel>? ReadList(MedicineSearchModel? model);
MedicineViewModel? ReadElement(MedicineSearchModel model);
bool Create(MedicineBindingModel model);
bool Update(MedicineBindingModel model);
bool Delete(MedicineBindingModel model);
}
}

View File

@ -0,0 +1,24 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BusinessLogicContracts
{
public interface IPatientLogic
{
List<PatientViewModel>? ReadList(PatientSearchModel? model);
PatientViewModel? ReadElement(PatientSearchModel model);
bool Create(PatientBindingModel model);
bool Update(PatientBindingModel model);
bool Delete(PatientBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using HospitalContracts.BindingModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalContracts.SearchModels;
namespace HospitalContracts.BusinessLogicContracts
{
public interface IPharmacistLogic
{
List<PharmacistViewModel>? ReadList(PharmacistSearchModel? model);
PharmacistViewModel? ReadElement(PharmacistSearchModel model);
bool Create(PharmacistBindingModel model);
bool Update(PharmacistBindingModel model);
bool Delete(PharmacistBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
namespace HospitalContracts.BusinessLogicContracts
{
public interface IProcedureLogic
{
List<ProcedureViewModel>? ReadList(ProcedureSearchModel? model);
ProcedureViewModel? ReadElement(ProcedureSearchModel model);
bool Create(ProcedureBindingModel model);
bool Update(ProcedureBindingModel model);
bool Delete(ProcedureBindingModel model);
}
}

View File

@ -0,0 +1,24 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BusinessLogicContracts
{
public interface IRecipeLogic
{
List<RecipeViewModel>? ReadList(RecipeSearchModel? model);
RecipeViewModel? ReadElement(RecipeSearchModel model);
bool Create(RecipeBindingModel model);
bool Update(RecipeBindingModel model);
bool Delete(RecipeBindingModel model);
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\HospitalDataModels\HospitalDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,12 @@
{
"profiles": {
"HospitalContracts": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:51160;http://localhost:51162"
}
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.SearchModels
{
public class DescriptionProcedureSearchModel
{
public int? Id { get; set; }
public string? Description { get; set; } = string.Empty;
public int? PharmacistId { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.SearchModels
{
public class DiseaseSearchModel
{
public int? Id { get; set; }
public string? Name { get; set; }
public string? Description { get; set; }
public int? DoctorId { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.SearchModels
{
public class DoctorSearchModel
{
public int? Id { get; set; }
public string? FIO { get; set; }
public string? Login { get; set; }
public string? Password { get; set; }
public string? MailAddress { get; set; }
public string? PhoneNumber { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.SearchModels
{
public class MedicineSearchModel
{
public int? Id { get; set; }
public string? Name { get; set; } = string.Empty;
public string? CountryOrigin { get; set; }
public double? Price { get; set; }
public int? PharmacistId { get; set; }
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.SearchModels
{
public class PatientSearchModel
{
public int? Id { get; set; }
public string? FIO { get; set; }
public string? Adress { get; set; }
public DateTime? BirthDate { get; set; }
public int? DoctorId { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
namespace HospitalContracts.SearchModels
{
public class PharmacistSearchModel
{
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; }
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.SearchModels
{
public class ProcedureSearchModel
{
public int? Id { get; set; }
public string? Name { get; set; } = string.Empty;
public DateTime? Date { get; set; }
public int? DescriptionOfTheProcedureId { get; set; }
public int? PharmacistId { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.SearchModels
{
public class RecipeSearchModel
{
public int? Id { get; set; }
public int? DoctorId { get; set; }
DateTime IssueDate { get; }
}
}

View File

@ -0,0 +1,21 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.StoragesContracts
{
public interface IDescriptionProcedureStorage
{
List<DescriptionProcedureViewModel> GetFullList();
List<DescriptionProcedureViewModel> GetFilteredList(DescriptionProcedureSearchModel model);
DescriptionProcedureViewModel? GetElement(DescriptionProcedureSearchModel model);
DescriptionProcedureViewModel? Insert(DescriptionProcedureBindingModel model);
DescriptionProcedureViewModel? Update(DescriptionProcedureBindingModel model);
DescriptionProcedureViewModel? Delete(DescriptionProcedureBindingModel model);
}
}

View File

@ -0,0 +1,26 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.StoragesContracts
{
public interface IDiseaseStorage
{
List<DiseaseViewModel> GetFullList();
List<DiseaseViewModel> GetFilteredList(DiseaseSearchModel model);
DiseaseViewModel? GetElement(DiseaseSearchModel model);
DiseaseViewModel? Insert(DiseaseBindingModel model);
DiseaseViewModel? Update(DiseaseBindingModel model);
DiseaseViewModel? Delete(DiseaseBindingModel model);
}
}

View File

@ -0,0 +1,26 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.StoragesContracts
{
public interface IDoctorStorage
{
List<DoctorViewModel> GetFullList();
List<DoctorViewModel> GetFilteredList(DoctorSearchModel model);
DoctorViewModel? GetElement(DoctorSearchModel model);
DoctorViewModel? Insert(DoctorBindingModel model);
DoctorViewModel? Update(DoctorBindingModel model);
DoctorViewModel? Delete(DoctorBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.StoragesContracts
{
public interface IMedicineStorage
{
List<MedicineViewModel> GetFullList();
List<MedicineViewModel> GetFilteredList(MedicineSearchModel model);
MedicineViewModel? GetElement(MedicineSearchModel model);
MedicineViewModel? Insert(MedicineBindingModel model);
MedicineViewModel? Update(MedicineBindingModel model);
MedicineViewModel? Delete(MedicineBindingModel model);
}
}

View File

@ -0,0 +1,26 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.StoragesContracts
{
public interface IPatientStorage
{
List<PatientViewModel> GetFullList();
List<PatientViewModel> GetFilteredList(PatientSearchModel model);
PatientViewModel? GetElement(PatientSearchModel model);
PatientViewModel? Insert(PatientBindingModel model);
PatientViewModel? Update(PatientBindingModel model);
PatientViewModel? Delete(PatientBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.StoragesContracts
{
public interface IPharmacistStorage
{
List<PharmacistViewModel> GetFullList();
List<PharmacistViewModel> GetFilteredList(PharmacistSearchModel model);
PharmacistViewModel? GetElement(PharmacistSearchModel model);
PharmacistViewModel? Insert(PharmacistBindingModel model);
PharmacistViewModel? Update(PharmacistBindingModel model);
PharmacistViewModel? Delete(PharmacistBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
namespace HospitalContracts.StoragesContracts
{
public interface IProcedureStorage
{
List<ProcedureViewModel> GetFullList();
List<ProcedureViewModel> GetFilteredList(ProcedureSearchModel model);
ProcedureViewModel? GetElement(ProcedureSearchModel model);
ProcedureViewModel? Insert(ProcedureBindingModel model);
ProcedureViewModel? Update(ProcedureBindingModel model);
ProcedureViewModel? Delete(ProcedureBindingModel model);
}
}

View File

@ -0,0 +1,27 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.StoragesContracts
{
public interface IRecipeStorage
{
List<RecipeViewModel> GetFullList();
List<RecipeViewModel> GetFilteredList(RecipeSearchModel model);
RecipeViewModel? GetElement(RecipeSearchModel model);
RecipeViewModel? Insert(RecipeBindingModel model);
RecipeViewModel? Update(RecipeBindingModel model);
RecipeViewModel? Delete(RecipeBindingModel model);
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalDataModels.Models;
namespace HospitalContracts.ViewModels
{
public class DescriptionProcedureViewModel : IDescriptionProcedureModel
{
public int Id { get; set; }
[DisplayName("Описание процедупы")]
public string Description { get; set; } = string.Empty;
[DisplayName("Фармацевт")]
public int PharmacistId { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using HospitalDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.ViewModels
{
public class DiseaseViewModel : IDiseaseModel
{
public int Id { get; set; }
[DisplayName("Название болезни")]
public string Name { get; set; } = string.Empty;
[DisplayName("Описание болезни")]
public string Description { get; set; } = string.Empty;
public int DoctorId { get; set; }
}
}

View File

@ -0,0 +1,30 @@
using HospitalDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.ViewModels
{
public class DoctorViewModel : IDoctorModel
{
public int Id { get; set; }
[DisplayName("ФИО")]
public string FIO { get; set; } = string.Empty;
[DisplayName("Логин")]
public string Login { get; set; } = string.Empty;
[DisplayName("Пароль")]
public string Password { get; set; } = string.Empty;
[DisplayName("Электронная почта")]
public string MailAddress { get; set; } = string.Empty;
[DisplayName("Номер телефона")]
public string PhoneNumber { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalDataModels.Models;
namespace HospitalContracts.ViewModels
{
public class MedicineViewModel : IMedicineModel
{
public int Id { get; set; }
[DisplayName("Название лекарства")]
public string Name { get; set; } = string.Empty;
[DisplayName("Цена лекарства")]
public double Price { get; set; }
[DisplayName("Страна производителя")]
public string CountryOrigin { get; set; } = string.Empty;
[DisplayName("Фармацевт")]
public int PharmacistId { get; set; }
public Dictionary<int, IRecipeModel> MedicineRecipes { get; set; } = new();
}
}

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalDataModels.Models;
namespace HospitalContracts.ViewModels
{
public class PatientViewModel : IPatientModel
{
[DisplayName("Номер")]
public int Id { get; set; }
[DisplayName("ФИО")]
public string FIO { get; set; } = string.Empty;
[DisplayName("Дата рождения")]
public DateTime BirthDate { get; set; } = new DateTime(Int32.Parse("2000"), Int32.Parse("01"), Int32.Parse("01"));
[DisplayName("Адрес")]
public string Address { get; set; } = string.Empty;
public int DoctorId { get; set; }
public Dictionary<int, IProcedureModel> PatientProcedures { get; set; } = new();
}
}

View File

@ -0,0 +1,23 @@
using HospitalDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.ViewModels
{
public class PharmacistViewModel : IPharmacistModel
{
public int Id { get; set; }
[DisplayName("ФИО кладовщика")]
public string FIO { get; set; } = string.Empty;
[DisplayName("Логин")]
public string Login { get; set; } = string.Empty;
[DisplayName("Пароль")]
public string Password { get; set; } = string.Empty;
[DisplayName("Номер телефона")]
public string PhoneNumber { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,26 @@
using HospitalDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.ViewModels
{
public class ProcedureViewModel : IProcedureModel
{
public int Id { get; set; }
[DisplayName("Название услуги")]
public string Name { get; set; } = string.Empty;
[DisplayName("Дата процедуры")]
public DateTime Date { get; set; }
[DisplayName("Фармацевт")]
public int PharmacistId { get; set; }
[DisplayName("Описание процедуры")]
public int DescriptionProcedureId { get; set; }
public Dictionary<int, IMedicineModel> ProcedureMedicines { get; set; } = new();
}
}

View File

@ -0,0 +1,25 @@
using HospitalDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.ViewModels
{
public class RecipeViewModel : IRecipeModel
{
public int Id { get; set; }
public string Description { get; set; } = string.Empty;
public DateTime IssueDate { get; set; } = DateTime.Now;
public int DiseaseId { get; set; }
public int DoctorId { get; set; }
public Dictionary<int, IPatientModel> RecipePatients { get; set; } = new();
}
}

View File

@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\HospitalContracts\HospitalContracts.csproj" />
<ProjectReference Include="..\HospitalDataModels\HospitalDataModels.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.17" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.17">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.17" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.17">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>

View File

@ -0,0 +1,46 @@
using HospitalDatabaseImplement.Models;
using HospitalDatabaseImplement.Modelss;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDatabaseImplement
{
public class HospitalDatabase : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=HospitalDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}
public virtual DbSet<Doctor> Doctors { set; get; }
public virtual DbSet<Patient> Patients { set; get; }
public virtual DbSet<Recipe> Recipes { set; get; }
public virtual DbSet<Disease> Diseases { set; get; }
public virtual DbSet<Medicine> Medicines { set; get; }
public virtual DbSet<Procedure> Procedures { set; get; }
public virtual DbSet<PatientRecipe> PatientRecipes { set; get; }
public virtual DbSet<PatientProcedure> PatientProcedures { set; get; }
public virtual DbSet<RecipeMedicine> RecipeMedicines { set; get; }
public virtual DbSet<ProcedureMedicine> ProcedureMedicines { set; get; }
public virtual DbSet<Pharmacist> Pharmacists { set; get; }
public virtual DbSet<DescriptionProcedure> DescriptionProcedures { set; get; }
}
}

View File

@ -0,0 +1,121 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.ViewModels;
using HospitalDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace HospitalDatabaseImplement.Implements
{
public class DescriptionProcedureStorage : IDescriptionProcedureStorage
{
public DescriptionProcedureViewModel? GetElement(DescriptionProcedureSearchModel model)
{
if (string.IsNullOrEmpty(model.Description) && !model.Id.HasValue)
{
return null;
}
using var context = new HospitalDatabase();
return context.DescriptionProcedures
.Include(x => x.Procedures)
.Include(x => x.Pharmacist)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Description) && x.Description == model.Description) || (model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public List<DescriptionProcedureViewModel> GetFilteredList(DescriptionProcedureSearchModel model)
{
using var context = new HospitalDatabase();
if (string.IsNullOrEmpty(model.Description) && !model.Id.HasValue)
{
return context.DescriptionProcedures
.Include(x => x.Procedures)
.Include(x => x.Pharmacist)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.PharmacistId.HasValue)
{
return context.DescriptionProcedures
.Include(x => x.Procedures)
.Include(x => x.Pharmacist)
.Where(x => x.PharmacistId == model.PharmacistId)
.Select(x => x.GetViewModel)
.ToList();
}
else
{
return new();
}
}
public List<DescriptionProcedureViewModel> GetFullList()
{
using var context = new HospitalDatabase();
return context.DescriptionProcedures
.Include(x => x.Procedures)
.Include(x => x.Pharmacist)
.Select(x => x.GetViewModel)
.ToList();
}
public DescriptionProcedureViewModel? Insert(DescriptionProcedureBindingModel model)
{
using var context = new HospitalDatabase();
var newDisease = DescriptionProcedure.Create(context, model);
if (newDisease == null)
{
return null;
}
context.DescriptionProcedures.Add(newDisease);
context.SaveChanges();
return context.DescriptionProcedures
.Include(x => x.Procedures)
.Include(x => x.Pharmacist)
.FirstOrDefault(x => x.Id == newDisease.Id)
?.GetViewModel;
}
public DescriptionProcedureViewModel? Update(DescriptionProcedureBindingModel model)
{
using var context = new HospitalDatabase();
var disease = context.DescriptionProcedures.FirstOrDefault(x => x.Id == model.Id);
if (disease == null)
{
return null;
}
disease.Update(context, model);
context.SaveChanges();
return context.DescriptionProcedures
.Include(x => x.Procedures)
.Include(x => x.Pharmacist)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
}
public DescriptionProcedureViewModel? Delete(DescriptionProcedureBindingModel model)
{
using var context = new HospitalDatabase();
var element = context.DescriptionProcedures.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
var deletedElement = context.DescriptionProcedures
.Include(x => x.Procedures)
.Include(x => x.Pharmacist)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
context.DescriptionProcedures.Remove(element);
context.SaveChanges();
return deletedElement;
}
return null;
}
}
}

View File

@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.ViewModels;
using Microsoft.EntityFrameworkCore;
using HospitalDatabaseImplement.Models;
namespace HospitalDatabaseImplement.Implements
{
public class MedicineStorage : IMedicineStorage
{
public List<MedicineViewModel> GetFullList()
{
using var context = new HospitalDatabase();
return context.Medicines
.Select(x => x.GetViewModel).ToList();
}
public List<MedicineViewModel> GetFilteredList(MedicineSearchModel model)
{
using var context = new HospitalDatabase();
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return context.Medicines
.Where(x => x.Name.Contains(model.Name)).ToList()
.Select(x => x.GetViewModel).ToList();
}
else
{
return new();
}
}
public MedicineViewModel? GetElement(MedicineSearchModel model)
{
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return null;
}
using var context = new HospitalDatabase();
return context.Medicines
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public MedicineViewModel? Insert(MedicineBindingModel model)
{
using var context = new HospitalDatabase();
var newMedicine = Medicine.Create(context, model);
if (newMedicine == null)
{
return null;
}
context.Medicines.Add(newMedicine);
context.SaveChanges();
return newMedicine.GetViewModel;
}
public MedicineViewModel? Update(MedicineBindingModel model)
{
using var context = new HospitalDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
var medicine = context.Medicines
.FirstOrDefault(rec => rec.Id == model.Id);
if (medicine == null)
{
return null;
}
medicine.Update(model);
context.SaveChanges();
transaction.Commit();
return medicine.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
public MedicineViewModel? Delete(MedicineBindingModel model)
{
using var context = new HospitalDatabase();
var element = context.Medicines
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Medicines.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.ViewModels;
using HospitalDatabaseImplement.Models;
using HospitalDatabaseImplement.Modelss;
using Microsoft.EntityFrameworkCore;
namespace HospitalDatabaseImplement.Implements
{
public class PharmacistStorage : IPharmacistStorage
{
public PharmacistViewModel? GetElement(PharmacistSearchModel model)
{
if (!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;
}
public List<PharmacistViewModel> GetFilteredList(PharmacistSearchModel model)
{
using var context = new HospitalDatabase();
if (!string.IsNullOrEmpty(model.Login))
{
return context.Pharmacists
.Include(x => x.Medicines)
.Include(x => x.Procedures)
.Include(x => x.DescriptionProcedures)
.Where(x => x.Login.Contains(model.Login))
.Select(x => x.GetViewModel)
.ToList();
}
return new();
}
public List<PharmacistViewModel> GetFullList()
{
using var context = new HospitalDatabase();
return context.Pharmacists
.Include(x => x.Medicines)
.Include(x => x.Procedures)
.Include(x => x.DescriptionProcedures)
.Select(x => x.GetViewModel)
.ToList();
}
public PharmacistViewModel? Insert(PharmacistBindingModel model)
{
var newDoctor = Pharmacist.Create(model);
if (newDoctor == null)
{
return null;
}
using var context = new HospitalDatabase();
context.Pharmacists.Add(newDoctor);
context.SaveChanges();
return context.Pharmacists
.Include(x => x.Medicines)
.Include(x => x.Procedures)
.Include(x => x.DescriptionProcedures)
.FirstOrDefault(x => x.Id == newDoctor.Id)
?.GetViewModel;
}
public PharmacistViewModel? Update(PharmacistBindingModel model)
{
using var context = new HospitalDatabase();
var doctor = context.Pharmacists.FirstOrDefault(x => x.Id == model.Id);
if (doctor == null)
{
return null;
}
doctor.Update(model);
context.SaveChanges();
return context.Pharmacists
.Include(x => x.Medicines)
.Include(x => x.Procedures)
.Include(x => x.DescriptionProcedures)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
}
public PharmacistViewModel? Delete(PharmacistBindingModel model)
{
using var context = new HospitalDatabase();
var element = context.Pharmacists.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
var deletedElement = context.Pharmacists
.Include(x => x.Medicines)
.Include(x => x.Procedures)
.Include(x => x.DescriptionProcedures)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
context.Pharmacists.Remove(element);
context.SaveChanges();
return deletedElement;
}
return null;
}
}
}

View File

@ -0,0 +1,67 @@
using HospitalContracts.BindingModels;
using HospitalContracts.ViewModels;
using HospitalDatabaseImplement.Modelss;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalDataModels.Models;
namespace HospitalDatabaseImplement.Models
{
public class DescriptionProcedure : IDescriptionProcedureModel
{
public int Id { get; set; }
public int PharmacistId { get; private set; }
public virtual Pharmacist Pharmacist { get; set; }
[Required]
[MaxLength(150)]
public string Description { get; set; } = string.Empty;
[ForeignKey("IDescriptionProcedureId")]
public virtual List<Procedure> Procedures { get; set; } = new();
public static DescriptionProcedure? Create(HospitalDatabase context, DescriptionProcedureBindingModel model)
{
if (model == null)
{
return null;
}
return new DescriptionProcedure()
{
Id = model.Id,
Description = model.Description,
PharmacistId = model.PharmacistId,
Pharmacist = context.Pharmacists.FirstOrDefault(x => x.Id == model.PharmacistId)
};
}
public void Update(HospitalDatabase context, DescriptionProcedureBindingModel model)
{
if (model == null)
{
return;
}
Description = model.Description;
PharmacistId = model.PharmacistId;
Pharmacist = context.Pharmacists.FirstOrDefault(x => x.Id == model.PharmacistId);
}
public DescriptionProcedureViewModel GetViewModel => new()
{
Id = Id,
Description = Description,
PharmacistId = PharmacistId
};
}
}

View File

@ -0,0 +1,12 @@
{
"profiles": {
"HospitalDatabaseImplement": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:51158;http://localhost:51165"
}
}
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Enums\**" />
<EmbeddedResource Remove="Enums\**" />
<None Remove="Enums\**" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,7 @@
namespace HospitalDataModels
{
public interface IId
{
int Id { get; }
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDataModels.Models
{
public interface IDescriptionProcedureModel : IId
{
string Description { get; }
int PharmacistId { get; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDataModels.Models
{
public interface IDiseaseModel : IId
{
string Name { get; }
string Description { get; }
int DoctorId { get; }
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDataModels.Models
{
public interface IDoctorModel : IId
{
string FIO { get; }
string Login { get; }
string Password { get; }
string MailAddress { get; }
string PhoneNumber { get; }
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDataModels.Models
{
public interface IMedicineModel : IId
{
string Name { get; }
string CountryOrigin { get; }
double Price { get; }
int PharmacistId { get; }
Dictionary<int, IRecipeModel> MedicineRecipes { get; }
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDataModels.Models
{
public interface IPatientModel : IId
{
string FIO { get; }
DateTime BirthDate { get; }
string Address { get; }
int DoctorId { get; }
Dictionary<int, IProcedureModel> PatientProcedures { get; }
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDataModels.Models
{
public interface IPharmacistModel : IId
{
string FIO { get; }
string Login { get; }
string Password { get; }
string PhoneNumber { get; }
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDataModels.Models
{
public interface IProcedureModel : IId
{
string Name { get; }
DateTime Date { get; }
int DescriptionProcedureId { get; }
int PharmacistId { get; }
Dictionary<int, IMedicineModel> ProcedureMedicines { get; }
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDataModels.Models
{
public interface IRecipeModel : IId
{
string Description { get; }
DateTime IssueDate { get; }
int DiseaseId { get; }
int DoctorId { get; }
Dictionary<int, IPatientModel> RecipePatients { get; }
}
}

View File

@ -0,0 +1,12 @@
{
"profiles": {
"HospitalDataModels": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:51161;http://localhost:51166"
}
}
}

View File

@ -0,0 +1,120 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.ViewModels;
using HospitalDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDatabaseImplement.Implementss
{
public class DiseaseStorage : IDiseaseStorage
{
public DiseaseViewModel? GetElement(DiseaseSearchModel model)
{
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return null;
}
using var context = new HospitalDatabase();
return context.Diseases
.Include(x => x.Recipes)
.Include(x => x.Doctor)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) || (model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public List<DiseaseViewModel> GetFilteredList(DiseaseSearchModel model)
{
using var context = new HospitalDatabase();
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return context.Diseases
.Include(x => x.Recipes)
.Include(x => x.Doctor)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.DoctorId.HasValue)
{
return context.Diseases
.Include(x => x.Recipes)
.Include(x => x.Doctor)
.Where(x => x.DoctorId == model.DoctorId)
.Select(x => x.GetViewModel)
.ToList();
}
else
{
return new();
}
}
public List<DiseaseViewModel> GetFullList()
{
using var context = new HospitalDatabase();
return context.Diseases
.Include(x => x.Recipes)
.Include(x => x.Doctor)
.Select(x => x.GetViewModel)
.ToList();
}
public DiseaseViewModel? Insert(DiseaseBindingModel model)
{
var newDisease = Disease.Create(model);
if (newDisease == null)
{
return null;
}
using var context = new HospitalDatabase();
context.Diseases.Add(newDisease);
context.SaveChanges();
return context.Diseases
.Include(x => x.Recipes)
.Include(x => x.Doctor)
.FirstOrDefault(x => x.Id == newDisease.Id)
?.GetViewModel;
}
public DiseaseViewModel? Update(DiseaseBindingModel model)
{
using var context = new HospitalDatabase();
var disease = context.Diseases.FirstOrDefault(x => x.Id == model.Id);
if (disease == null)
{
return null;
}
disease.Update(model);
context.SaveChanges();
return context.Diseases
.Include(x => x.Recipes)
.Include(x => x.Doctor)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
}
public DiseaseViewModel? Delete(DiseaseBindingModel model)
{
using var context = new HospitalDatabase();
var element = context.Diseases.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
var deletedElement = context.Diseases
.Include(x => x.Recipes)
.Include(x => x.Doctor)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
context.Diseases.Remove(element);
context.SaveChanges();
return deletedElement;
}
return null;
}
}
}

View File

@ -0,0 +1,114 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.ViewModels;
using HospitalDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDatabaseImplement.Implementss
{
public class DoctorStorage : IDoctorStorage
{
public DoctorViewModel? GetElement(DoctorSearchModel model)
{
if ((string.IsNullOrEmpty(model.Login) && !model.Id.HasValue))
{
return null;
}
using var context = new HospitalDatabase();
return context.Doctors
.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<DoctorViewModel> GetFilteredList(DoctorSearchModel model)
{
using var context = new HospitalDatabase();
if (!string.IsNullOrEmpty(model.Login))
{
return context.Doctors
.Include(x => x.Recipes)
.Include(x => x.Diseases)
.Include(x => x.Patients)
.Where(x => x.Login.Contains(model.Login))
.Select(x => x.GetViewModel)
.ToList();
}
return new();
}
public List<DoctorViewModel> GetFullList()
{
using var context = new HospitalDatabase();
return context.Doctors
.Include(x => x.Recipes)
.Include(x => x.Diseases)
.Include(x => x.Patients)
.Select(x => x.GetViewModel)
.ToList();
}
public DoctorViewModel? Insert(DoctorBindingModel model)
{
var newDoctor = Doctor.Create(model);
if (newDoctor == null)
{
return null;
}
using var context = new HospitalDatabase();
context.Doctors.Add(newDoctor);
context.SaveChanges();
return context.Doctors
.Include(x => x.Recipes)
.Include(x => x.Diseases)
.Include(x => x.Patients)
.FirstOrDefault(x => x.Id == newDoctor.Id)
?.GetViewModel;
}
public DoctorViewModel? Update(DoctorBindingModel model)
{
using var context = new HospitalDatabase();
var doctor = context.Doctors.FirstOrDefault(x => x.Id == model.Id);
if (doctor == null)
{
return null;
}
doctor.Update(model);
context.SaveChanges();
return context.Doctors
.Include(x => x.Recipes)
.Include(x => x.Diseases)
.Include(x => x.Patients)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
}
public DoctorViewModel? Delete(DoctorBindingModel model)
{
using var context = new HospitalDatabase();
var element = context.Doctors.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
var deletedElement = context.Doctors
.Include(x => x.Recipes)
.Include(x => x.Diseases)
.Include(x => x.Patients)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
context.Doctors.Remove(element);
context.SaveChanges();
return deletedElement;
}
return null;
}
}
}

View File

@ -0,0 +1,122 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.ViewModels;
using HospitalDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDatabaseImplement.Implementss
{
public class PatientStorage : IPatientStorage
{
public PatientViewModel? GetElement(PatientSearchModel model)
{
if (string.IsNullOrEmpty(model.FIO) && !model.Id.HasValue)
{
return null;
}
using var context = new HospitalDatabase();
return context.Patients
.Include(x => x.Doctor)
.Include(x => x.Recipes)
.ThenInclude(x => x.Recipe)
.FirstOrDefault(x => ((!string.IsNullOrEmpty(model.FIO) && x.FIO == model.FIO)
|| (model.Id.HasValue && x.Id == model.Id)))?.GetViewModel;
}
public List<PatientViewModel> GetFilteredList(PatientSearchModel model)
{
using var context = new HospitalDatabase();
if (!string.IsNullOrEmpty(model.FIO) )
{
return context.Patients
.Include(x => x.Doctor)
.Include(x => x.Recipes)
.ThenInclude(x => x.Recipe)
.Where(x => (x.Id == model.Id)).ToList()
.Select(x => x.GetViewModel).ToList();
}
else if (model.DoctorId.HasValue)
{
return context.Patients
.Include(x => x.Doctor)
.Include(x => x.Recipes)
.ThenInclude(x => x.Recipe)
.Where(x => x.DoctorId == model.DoctorId)
.Select(x => x.GetViewModel).ToList();
}
else
{
return new();
}
}
public List<PatientViewModel> GetFullList()
{
using var context = new HospitalDatabase();
return context.Patients
.Include(x => x.Doctor)
.Include(x => x.Recipes)
.ThenInclude(x => x.Recipe).ToList()
.Select(x => x.GetViewModel).ToList();
}
public PatientViewModel? Insert(PatientBindingModel model)
{
using var context = new HospitalDatabase();
var newPatient = Patient.Create(context, model);
if (newPatient == null)
{
return null;
}
context.Patients.Add(newPatient);
context.SaveChanges();
return newPatient.GetViewModel;
}
public PatientViewModel? Update(PatientBindingModel model)
{
using var context = new HospitalDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
var patient = context.Patients.FirstOrDefault(rec => rec.Id == model.Id);
if (patient == null)
{
return null;
}
patient.Update(model);
context.SaveChanges();
patient.UpdateProcedures(context, model);
transaction.Commit();
return patient.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
public PatientViewModel? Delete(PatientBindingModel model)
{
using var context = new HospitalDatabase();
var element = context.Patients
.Include(x => x.Doctor)
.Include(x => x.Recipes)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Patients.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,108 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.ViewModels;
using HospitalDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDatabaseImplement.Implements
{
public class ProcedureStorage : IProcedureStorage
{
public List<ProcedureViewModel> GetFullList()
{
using var context = new HospitalDatabase();
return context.Procedures
.Include(x => x.Medicines)
.Select(x => x.GetViewModel)
.ToList();
}
public List<ProcedureViewModel> GetFilteredList(ProcedureSearchModel model)
{
using var context = new HospitalDatabase();
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return context.Procedures
.Include(x => x.Medicines)
.Where(x => x.Name.Contains(model.Name))
.Select(x => x.GetViewModel).ToList();
}
else
{
return new();
}
}
public ProcedureViewModel? GetElement(ProcedureSearchModel model)
{
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return null;
}
using var context = new HospitalDatabase();
return context.Procedures
.Include(x => x.Medicines)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) || (model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public ProcedureViewModel? Insert(ProcedureBindingModel model)
{
using var context = new HospitalDatabase();
var newProcedure = Procedure.Create(context, model);
if (newProcedure == null)
{
return null;
}
context.Procedures.Add(newProcedure);
context.SaveChanges();
return newProcedure.GetViewModel;
}
public ProcedureViewModel? Update(ProcedureBindingModel model)
{
using var context = new HospitalDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
var procedure = context.Procedures
.FirstOrDefault(rec => rec.Id == model.Id);
if (procedure == null)
{
return null;
}
procedure.Update(model);
context.SaveChanges();
procedure.UpdateMedicines(context, model);
transaction.Commit();
return procedure.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
public ProcedureViewModel? Delete(ProcedureBindingModel model)
{
using var context = new HospitalDatabase();
var element = context.Procedures
.Include(x => x.Medicines)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Procedures.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,123 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.ViewModels;
using HospitalDatabaseImplement.Modelss;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDatabaseImplement.Implementss
{
public class RecipeStorage : IRecipeStorage
{
public List<RecipeViewModel> GetFullList()
{
using var context = new HospitalDatabase();
return context.Recipes
.Include(x => x.Doctor)
.Include(x => x.DiseaseId)
.Select(x => x.GetViewModel).ToList();
}
public List<RecipeViewModel> GetFilteredList(RecipeSearchModel model)
{
using var context = new HospitalDatabase();
if (!model.Id.HasValue)
{
return context.Recipes
.Include(x => x.Doctor)
.Include(x => x.Patients)
.ThenInclude(x => x.Patient)
.Where(x => x.Id == model.Id).ToList()
.Select(x => x.GetViewModel).ToList();
}
else if (model.DoctorId.HasValue)
{
return context.Recipes
.Include(x => x.Doctor)
.Include(x => x.Patients)
.ThenInclude(x => x.Patient)
.Where(x => x.DoctorId == model.DoctorId)
.Select(x => x.GetViewModel).ToList();
}
else
{
return new();
}
}
public RecipeViewModel? GetElement(RecipeSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new HospitalDatabase();
return context.Recipes
.Include(x => x.Doctor)
.Include(x => x.Patients)
.ThenInclude(x => x.Patient)
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
?.GetViewModel;
}
public RecipeViewModel? Insert(RecipeBindingModel model)
{
using var context = new HospitalDatabase();
var newRecipe = Recipe.Create(context, model);
if (newRecipe == null)
{
return null;
}
context.Recipes.Add(newRecipe);
context.SaveChanges();
return newRecipe.GetViewModel;
}
public RecipeViewModel? Update(RecipeBindingModel model)
{
using var context = new HospitalDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
var recipe = context.Recipes
.Include(x => x.Doctor)
.FirstOrDefault(rec => rec.Id == model.Id);
if (recipe == null)
{
return null;
}
recipe.Update(model);
context.SaveChanges();
recipe.UpdatePatients(context, model);
transaction.Commit();
return recipe.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
public RecipeViewModel? Delete(RecipeBindingModel model)
{
using var context = new HospitalDatabase();
var element = context.Recipes
.Include(x => x.Doctor)
.Include(x => x.Patients)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Recipes.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,581 @@
// <auto-generated />
using System;
using HospitalDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace HospitalDatabaseImplement.Migrations
{
[DbContext(typeof(HospitalDatabase))]
[Migration("20240430102720_InitCreate")]
partial class InitCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.17")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("HospitalDatabaseImplement.Models.DescriptionProcedure", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<int>("PharmacistId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PharmacistId");
b.ToTable("DescriptionProcedures");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Disease", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<int>("DoctorId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.HasKey("Id");
b.HasIndex("DoctorId");
b.ToTable("Diseases");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Doctor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("FIO")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("Login")
.IsRequired()
.HasMaxLength(25)
.HasColumnType("nvarchar(25)");
b.Property<string>("MailAddress")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasMaxLength(11)
.HasColumnType("nvarchar(11)");
b.HasKey("Id");
b.ToTable("Doctors");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Medicine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("CountryOrigin")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<int>("PharmacistId")
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("PharmacistId");
b.ToTable("Medicines");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<DateTime>("BirthDate")
.HasColumnType("datetime2");
b.Property<int>("DoctorId")
.HasColumnType("int");
b.Property<string>("FIO")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.HasKey("Id");
b.HasIndex("DoctorId");
b.ToTable("Patients");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientProcedure", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("PatientId")
.HasColumnType("int");
b.Property<int>("ProcedureId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PatientId");
b.HasIndex("ProcedureId");
b.ToTable("PatientProcedures");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientRecipe", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("PatientId")
.HasColumnType("int");
b.Property<int>("RecipeId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PatientId");
b.HasIndex("RecipeId");
b.ToTable("PatientRecipes");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Pharmacist", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("FIO")
.IsRequired()
.HasMaxLength(55)
.HasColumnType("nvarchar(55)");
b.Property<string>("Login")
.IsRequired()
.HasMaxLength(25)
.HasColumnType("nvarchar(25)");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasMaxLength(11)
.HasColumnType("nvarchar(11)");
b.HasKey("Id");
b.ToTable("Pharmacists");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Procedure", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("Date")
.HasColumnType("datetime2");
b.Property<int>("DescriptionProcedureId")
.HasColumnType("int");
b.Property<int>("IDescriptionProcedureId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<int>("PharmacistId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("IDescriptionProcedureId");
b.HasIndex("PharmacistId");
b.ToTable("Procedures");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.ProcedureMedicine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("MedicineId")
.HasColumnType("int");
b.Property<int>("ProcedureId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("MedicineId");
b.HasIndex("ProcedureId");
b.ToTable("ProcedureMedicines");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.RecipeMedicine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("MedicineId")
.HasColumnType("int");
b.Property<int>("RecipeId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("MedicineId");
b.HasIndex("RecipeId");
b.ToTable("RecipeMedicines");
});
modelBuilder.Entity("HospitalDatabaseImplement.Modelss.Recipe", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("DiseaseId")
.HasColumnType("int");
b.Property<int>("DoctorId")
.HasColumnType("int");
b.Property<DateTime>("IssueDate")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("DiseaseId");
b.HasIndex("DoctorId");
b.ToTable("Recipes");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.DescriptionProcedure", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Pharmacist", "Pharmacist")
.WithMany("DescriptionProcedures")
.HasForeignKey("PharmacistId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Pharmacist");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Disease", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Doctor", "Doctor")
.WithMany("Diseases")
.HasForeignKey("DoctorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Doctor");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Medicine", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Pharmacist", "Pharmacist")
.WithMany("Medicines")
.HasForeignKey("PharmacistId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Pharmacist");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Doctor", "Doctor")
.WithMany("Patients")
.HasForeignKey("DoctorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Doctor");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientProcedure", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Patient", "Patient")
.WithMany("Procedures")
.HasForeignKey("PatientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HospitalDatabaseImplement.Models.Procedure", "Procedure")
.WithMany("PatientProcedures")
.HasForeignKey("ProcedureId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Patient");
b.Navigation("Procedure");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientRecipe", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Patient", "Patient")
.WithMany("Recipes")
.HasForeignKey("PatientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HospitalDatabaseImplement.Modelss.Recipe", "Recipe")
.WithMany("Patients")
.HasForeignKey("RecipeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Patient");
b.Navigation("Recipe");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Procedure", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.DescriptionProcedure", "DescriptionProcedure")
.WithMany("Procedures")
.HasForeignKey("IDescriptionProcedureId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HospitalDatabaseImplement.Models.Pharmacist", "Pharmacist")
.WithMany("Procedures")
.HasForeignKey("PharmacistId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DescriptionProcedure");
b.Navigation("Pharmacist");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.ProcedureMedicine", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Medicine", "Medicine")
.WithMany("Services")
.HasForeignKey("MedicineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HospitalDatabaseImplement.Models.Procedure", "Procedure")
.WithMany("Medicines")
.HasForeignKey("ProcedureId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Medicine");
b.Navigation("Procedure");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.RecipeMedicine", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Medicine", "Medicine")
.WithMany("Recipes")
.HasForeignKey("MedicineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HospitalDatabaseImplement.Modelss.Recipe", "Recipe")
.WithMany()
.HasForeignKey("RecipeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Medicine");
b.Navigation("Recipe");
});
modelBuilder.Entity("HospitalDatabaseImplement.Modelss.Recipe", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Disease", "Disease")
.WithMany("Recipes")
.HasForeignKey("DiseaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HospitalDatabaseImplement.Models.Doctor", "Doctor")
.WithMany("Recipes")
.HasForeignKey("DoctorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Disease");
b.Navigation("Doctor");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.DescriptionProcedure", b =>
{
b.Navigation("Procedures");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Disease", b =>
{
b.Navigation("Recipes");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Doctor", b =>
{
b.Navigation("Diseases");
b.Navigation("Patients");
b.Navigation("Recipes");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Medicine", b =>
{
b.Navigation("Recipes");
b.Navigation("Services");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b =>
{
b.Navigation("Procedures");
b.Navigation("Recipes");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Pharmacist", b =>
{
b.Navigation("DescriptionProcedures");
b.Navigation("Medicines");
b.Navigation("Procedures");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Procedure", b =>
{
b.Navigation("Medicines");
b.Navigation("PatientProcedures");
});
modelBuilder.Entity("HospitalDatabaseImplement.Modelss.Recipe", b =>
{
b.Navigation("Patients");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,414 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace HospitalDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Doctors",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Login = table.Column<string>(type: "nvarchar(25)", maxLength: 25, nullable: false),
PhoneNumber = table.Column<string>(type: "nvarchar(11)", maxLength: 11, nullable: false),
Password = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
FIO = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
MailAddress = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Doctors", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Pharmacists",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Login = table.Column<string>(type: "nvarchar(25)", maxLength: 25, nullable: false),
FIO = table.Column<string>(type: "nvarchar(55)", maxLength: 55, nullable: false),
PhoneNumber = table.Column<string>(type: "nvarchar(11)", maxLength: 11, nullable: false),
Password = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Pharmacists", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Diseases",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
DoctorId = table.Column<int>(type: "int", nullable: false),
Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
Description = table.Column<string>(type: "nvarchar(150)", maxLength: 150, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Diseases", x => x.Id);
table.ForeignKey(
name: "FK_Diseases_Doctors_DoctorId",
column: x => x.DoctorId,
principalTable: "Doctors",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Patients",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
DoctorId = table.Column<int>(type: "int", nullable: false),
FIO = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
Address = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
BirthDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Patients", x => x.Id);
table.ForeignKey(
name: "FK_Patients_Doctors_DoctorId",
column: x => x.DoctorId,
principalTable: "Doctors",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "DescriptionProcedures",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PharmacistId = table.Column<int>(type: "int", nullable: false),
Description = table.Column<string>(type: "nvarchar(150)", maxLength: 150, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DescriptionProcedures", x => x.Id);
table.ForeignKey(
name: "FK_DescriptionProcedures_Pharmacists_PharmacistId",
column: x => x.PharmacistId,
principalTable: "Pharmacists",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Medicines",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
CountryOrigin = table.Column<string>(type: "nvarchar(max)", nullable: false),
Price = table.Column<double>(type: "float", nullable: false),
PharmacistId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Medicines", x => x.Id);
table.ForeignKey(
name: "FK_Medicines_Pharmacists_PharmacistId",
column: x => x.PharmacistId,
principalTable: "Pharmacists",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Recipes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
DoctorId = table.Column<int>(type: "int", nullable: false),
DiseaseId = table.Column<int>(type: "int", nullable: false),
IssueDate = table.Column<DateTime>(type: "datetime2", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Recipes", x => x.Id);
table.ForeignKey(
name: "FK_Recipes_Diseases_DiseaseId",
column: x => x.DiseaseId,
principalTable: "Diseases",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Recipes_Doctors_DoctorId",
column: x => x.DoctorId,
principalTable: "Doctors",
principalColumn: "Id"
);
});
migrationBuilder.CreateTable(
name: "Procedures",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
Date = table.Column<DateTime>(type: "datetime2", nullable: false),
DescriptionProcedureId = table.Column<int>(type: "int", nullable: false),
IDescriptionProcedureId = table.Column<int>(type: "int", nullable: false),
PharmacistId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Procedures", x => x.Id);
table.ForeignKey(
name: "FK_Procedures_DescriptionProcedures_IDescriptionProcedureId",
column: x => x.IDescriptionProcedureId,
principalTable: "DescriptionProcedures",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Procedures_Pharmacists_PharmacistId",
column: x => x.PharmacistId,
principalTable: "Pharmacists",
principalColumn: "Id"
);
});
migrationBuilder.CreateTable(
name: "PatientRecipes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PatientId = table.Column<int>(type: "int", nullable: false),
RecipeId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PatientRecipes", x => x.Id);
table.ForeignKey(
name: "FK_PatientRecipes_Patients_PatientId",
column: x => x.PatientId,
principalTable: "Patients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PatientRecipes_Recipes_RecipeId",
column: x => x.RecipeId,
principalTable: "Recipes",
principalColumn: "Id"
);
});
migrationBuilder.CreateTable(
name: "RecipeMedicines",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
RecipeId = table.Column<int>(type: "int", nullable: false),
MedicineId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RecipeMedicines", x => x.Id);
table.ForeignKey(
name: "FK_RecipeMedicines_Medicines_MedicineId",
column: x => x.MedicineId,
principalTable: "Medicines",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RecipeMedicines_Recipes_RecipeId",
column: x => x.RecipeId,
principalTable: "Recipes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "PatientProcedures",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PatientId = table.Column<int>(type: "int", nullable: false),
ProcedureId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PatientProcedures", x => x.Id);
table.ForeignKey(
name: "FK_PatientProcedures_Patients_PatientId",
column: x => x.PatientId,
principalTable: "Patients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PatientProcedures_Procedures_ProcedureId",
column: x => x.ProcedureId,
principalTable: "Procedures",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ProcedureMedicines",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ProcedureId = table.Column<int>(type: "int", nullable: false),
MedicineId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProcedureMedicines", x => x.Id);
table.ForeignKey(
name: "FK_ProcedureMedicines_Medicines_MedicineId",
column: x => x.MedicineId,
principalTable: "Medicines",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ProcedureMedicines_Procedures_ProcedureId",
column: x => x.ProcedureId,
principalTable: "Procedures",
principalColumn: "Id"
);
});
migrationBuilder.CreateIndex(
name: "IX_DescriptionProcedures_PharmacistId",
table: "DescriptionProcedures",
column: "PharmacistId");
migrationBuilder.CreateIndex(
name: "IX_Diseases_DoctorId",
table: "Diseases",
column: "DoctorId");
migrationBuilder.CreateIndex(
name: "IX_Medicines_PharmacistId",
table: "Medicines",
column: "PharmacistId");
migrationBuilder.CreateIndex(
name: "IX_PatientProcedures_PatientId",
table: "PatientProcedures",
column: "PatientId");
migrationBuilder.CreateIndex(
name: "IX_PatientProcedures_ProcedureId",
table: "PatientProcedures",
column: "ProcedureId");
migrationBuilder.CreateIndex(
name: "IX_PatientRecipes_PatientId",
table: "PatientRecipes",
column: "PatientId");
migrationBuilder.CreateIndex(
name: "IX_PatientRecipes_RecipeId",
table: "PatientRecipes",
column: "RecipeId");
migrationBuilder.CreateIndex(
name: "IX_Patients_DoctorId",
table: "Patients",
column: "DoctorId");
migrationBuilder.CreateIndex(
name: "IX_ProcedureMedicines_MedicineId",
table: "ProcedureMedicines",
column: "MedicineId");
migrationBuilder.CreateIndex(
name: "IX_ProcedureMedicines_ProcedureId",
table: "ProcedureMedicines",
column: "ProcedureId");
migrationBuilder.CreateIndex(
name: "IX_Procedures_IDescriptionProcedureId",
table: "Procedures",
column: "IDescriptionProcedureId");
migrationBuilder.CreateIndex(
name: "IX_Procedures_PharmacistId",
table: "Procedures",
column: "PharmacistId");
migrationBuilder.CreateIndex(
name: "IX_RecipeMedicines_MedicineId",
table: "RecipeMedicines",
column: "MedicineId");
migrationBuilder.CreateIndex(
name: "IX_RecipeMedicines_RecipeId",
table: "RecipeMedicines",
column: "RecipeId");
migrationBuilder.CreateIndex(
name: "IX_Recipes_DiseaseId",
table: "Recipes",
column: "DiseaseId");
migrationBuilder.CreateIndex(
name: "IX_Recipes_DoctorId",
table: "Recipes",
column: "DoctorId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PatientProcedures");
migrationBuilder.DropTable(
name: "PatientRecipes");
migrationBuilder.DropTable(
name: "ProcedureMedicines");
migrationBuilder.DropTable(
name: "RecipeMedicines");
migrationBuilder.DropTable(
name: "Patients");
migrationBuilder.DropTable(
name: "Procedures");
migrationBuilder.DropTable(
name: "Medicines");
migrationBuilder.DropTable(
name: "Recipes");
migrationBuilder.DropTable(
name: "DescriptionProcedures");
migrationBuilder.DropTable(
name: "Diseases");
migrationBuilder.DropTable(
name: "Pharmacists");
migrationBuilder.DropTable(
name: "Doctors");
}
}
}

View File

@ -0,0 +1,578 @@
// <auto-generated />
using System;
using HospitalDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace HospitalDatabaseImplement.Migrations
{
[DbContext(typeof(HospitalDatabase))]
partial class HospitalDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.17")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("HospitalDatabaseImplement.Models.DescriptionProcedure", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<int>("PharmacistId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PharmacistId");
b.ToTable("DescriptionProcedures");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Disease", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<int>("DoctorId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.HasKey("Id");
b.HasIndex("DoctorId");
b.ToTable("Diseases");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Doctor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("FIO")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("Login")
.IsRequired()
.HasMaxLength(25)
.HasColumnType("nvarchar(25)");
b.Property<string>("MailAddress")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasMaxLength(11)
.HasColumnType("nvarchar(11)");
b.HasKey("Id");
b.ToTable("Doctors");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Medicine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("CountryOrigin")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<int>("PharmacistId")
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("PharmacistId");
b.ToTable("Medicines");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<DateTime>("BirthDate")
.HasColumnType("datetime2");
b.Property<int>("DoctorId")
.HasColumnType("int");
b.Property<string>("FIO")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.HasKey("Id");
b.HasIndex("DoctorId");
b.ToTable("Patients");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientProcedure", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("PatientId")
.HasColumnType("int");
b.Property<int>("ProcedureId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PatientId");
b.HasIndex("ProcedureId");
b.ToTable("PatientProcedures");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientRecipe", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("PatientId")
.HasColumnType("int");
b.Property<int>("RecipeId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PatientId");
b.HasIndex("RecipeId");
b.ToTable("PatientRecipes");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Pharmacist", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("FIO")
.IsRequired()
.HasMaxLength(55)
.HasColumnType("nvarchar(55)");
b.Property<string>("Login")
.IsRequired()
.HasMaxLength(25)
.HasColumnType("nvarchar(25)");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasMaxLength(11)
.HasColumnType("nvarchar(11)");
b.HasKey("Id");
b.ToTable("Pharmacists");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Procedure", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("Date")
.HasColumnType("datetime2");
b.Property<int>("DescriptionProcedureId")
.HasColumnType("int");
b.Property<int>("IDescriptionProcedureId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<int>("PharmacistId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("IDescriptionProcedureId");
b.HasIndex("PharmacistId");
b.ToTable("Procedures");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.ProcedureMedicine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("MedicineId")
.HasColumnType("int");
b.Property<int>("ProcedureId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("MedicineId");
b.HasIndex("ProcedureId");
b.ToTable("ProcedureMedicines");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.RecipeMedicine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("MedicineId")
.HasColumnType("int");
b.Property<int>("RecipeId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("MedicineId");
b.HasIndex("RecipeId");
b.ToTable("RecipeMedicines");
});
modelBuilder.Entity("HospitalDatabaseImplement.Modelss.Recipe", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("DiseaseId")
.HasColumnType("int");
b.Property<int>("DoctorId")
.HasColumnType("int");
b.Property<DateTime>("IssueDate")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("DiseaseId");
b.HasIndex("DoctorId");
b.ToTable("Recipes");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.DescriptionProcedure", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Pharmacist", "Pharmacist")
.WithMany("DescriptionProcedures")
.HasForeignKey("PharmacistId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Pharmacist");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Disease", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Doctor", "Doctor")
.WithMany("Diseases")
.HasForeignKey("DoctorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Doctor");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Medicine", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Pharmacist", "Pharmacist")
.WithMany("Medicines")
.HasForeignKey("PharmacistId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Pharmacist");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Doctor", "Doctor")
.WithMany("Patients")
.HasForeignKey("DoctorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Doctor");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientProcedure", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Patient", "Patient")
.WithMany("Procedures")
.HasForeignKey("PatientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HospitalDatabaseImplement.Models.Procedure", "Procedure")
.WithMany("PatientProcedures")
.HasForeignKey("ProcedureId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Patient");
b.Navigation("Procedure");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientRecipe", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Patient", "Patient")
.WithMany("Recipes")
.HasForeignKey("PatientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HospitalDatabaseImplement.Modelss.Recipe", "Recipe")
.WithMany("Patients")
.HasForeignKey("RecipeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Patient");
b.Navigation("Recipe");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Procedure", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.DescriptionProcedure", "DescriptionProcedure")
.WithMany("Procedures")
.HasForeignKey("IDescriptionProcedureId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HospitalDatabaseImplement.Models.Pharmacist", "Pharmacist")
.WithMany("Procedures")
.HasForeignKey("PharmacistId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DescriptionProcedure");
b.Navigation("Pharmacist");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.ProcedureMedicine", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Medicine", "Medicine")
.WithMany("Services")
.HasForeignKey("MedicineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HospitalDatabaseImplement.Models.Procedure", "Procedure")
.WithMany("Medicines")
.HasForeignKey("ProcedureId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Medicine");
b.Navigation("Procedure");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.RecipeMedicine", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Medicine", "Medicine")
.WithMany("Recipes")
.HasForeignKey("MedicineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HospitalDatabaseImplement.Modelss.Recipe", "Recipe")
.WithMany()
.HasForeignKey("RecipeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Medicine");
b.Navigation("Recipe");
});
modelBuilder.Entity("HospitalDatabaseImplement.Modelss.Recipe", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Disease", "Disease")
.WithMany("Recipes")
.HasForeignKey("DiseaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HospitalDatabaseImplement.Models.Doctor", "Doctor")
.WithMany("Recipes")
.HasForeignKey("DoctorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Disease");
b.Navigation("Doctor");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.DescriptionProcedure", b =>
{
b.Navigation("Procedures");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Disease", b =>
{
b.Navigation("Recipes");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Doctor", b =>
{
b.Navigation("Diseases");
b.Navigation("Patients");
b.Navigation("Recipes");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Medicine", b =>
{
b.Navigation("Recipes");
b.Navigation("Services");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b =>
{
b.Navigation("Procedures");
b.Navigation("Recipes");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Pharmacist", b =>
{
b.Navigation("DescriptionProcedures");
b.Navigation("Medicines");
b.Navigation("Procedures");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Procedure", b =>
{
b.Navigation("Medicines");
b.Navigation("PatientProcedures");
});
modelBuilder.Entity("HospitalDatabaseImplement.Modelss.Recipe", b =>
{
b.Navigation("Patients");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,77 @@
using HospitalContracts.BindingModels;
using HospitalContracts.ViewModels;
using HospitalDatabaseImplement.Modelss;
using HospitalDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDatabaseImplement.Models
{
public class Disease : IDiseaseModel
{
public int Id { get; set; }
public int DoctorId { get; private set; }
public virtual Doctor Doctor { get; set; }
[Required]
[MaxLength(50)]
public string Name { get; set; } = string.Empty;
[Required]
[MaxLength(150)]
public string Description { get; set; } = string.Empty;
[ForeignKey("DiseaseId")]
public virtual List<Recipe> Recipes { get; set; } = new();
public static Disease? Create(DiseaseBindingModel model)
{
if (model == null)
{
return null;
}
return new Disease()
{
//Id = model.Id,
Name = model.Name,
Description = model.Description,
DoctorId = model.DoctorId
};
}
public static Disease Create(DiseaseViewModel model)
{
return new Disease
{
Id = model.Id,
Name = model.Name,
Description = model.Description
};
}
public void Update(DiseaseBindingModel model)
{
if (model == null)
{
return;
}
Name = model.Name;
Description = model.Description;
}
public DiseaseViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Description = Description
};
}
}

View File

@ -0,0 +1,98 @@
using HospitalContracts.BindingModels;
using HospitalContracts.ViewModels;
using HospitalDatabaseImplement.Modelss;
using HospitalDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDatabaseImplement.Models
{
public class Doctor : IDoctorModel
{
public int Id { get; set; }
[Required]
[MaxLength(25)]
public string Login { get; set; } = string.Empty;
[Required]
[MaxLength(11)]
public string PhoneNumber { get; set; } = string.Empty;
[Required]
[MaxLength(30)]
public string Password { get; set; } = string.Empty;
[Required]
[MaxLength(30)]
public string FIO { get; set; } = string.Empty;
[Required]
[MaxLength(30)]
public string MailAddress { get; set; } = string.Empty;
[ForeignKey("DoctorId")]
public virtual List<Patient> Patients { get; set; } = new();
[ForeignKey("DoctorId")]
public virtual List<Recipe> Recipes { get; set; } = new();
[ForeignKey("DoctorId")]
public virtual List<Disease> Diseases { get; set; } = new();
public static Doctor? Create(DoctorBindingModel model)
{
if (model == null)
{
return null;
}
return new Doctor()
{
//Id = model.Id,
Login = model.Login,
PhoneNumber = model.PhoneNumber,
Password = model.Password,
FIO = model.FIO,
MailAddress = model.MailAddress
};
}
public static Doctor Create(DoctorViewModel model)
{
return new Doctor
{
Id = model.Id,
Login = model.Login,
PhoneNumber = model.PhoneNumber,
Password = model.Password,
FIO = model.FIO,
MailAddress = model.MailAddress
};
}
public void Update(DoctorBindingModel model)
{
if (model == null)
{
return;
}
Login = model.Login;
PhoneNumber = model.PhoneNumber;
Password = model.Password;
FIO = model.FIO;
MailAddress = model.MailAddress;
}
public DoctorViewModel GetViewModel => new()
{
Id = Id,
Login = Login,
PhoneNumber = PhoneNumber,
Password = Password,
FIO = FIO,
MailAddress = MailAddress
};
}
}

View File

@ -0,0 +1,114 @@
using HospitalContracts.BindingModels;
using HospitalContracts.ViewModels;
using HospitalDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalDatabaseImplement.Models;
namespace HospitalDatabaseImplement.Models
{
public class Medicine : IMedicineModel
{
public int Id { get; set; }
[Required]
[MaxLength(50)]
public string Name { get; set; } = string.Empty;
[Required]
public string CountryOrigin { get; set; } = string.Empty;
[Required]
public double Price { get; set; }
public int PharmacistId { get; private set; }
public virtual Pharmacist Pharmacist { get; set; }
private Dictionary<int, IRecipeModel>? _medicineRecipes =
null;
[NotMapped]
public Dictionary<int, IRecipeModel> MedicineRecipes
{
get
{
if (_medicineRecipes == null)
{
_medicineRecipes = Recipes
.ToDictionary(recPC => recPC.RecipeId, recPC =>
recPC.Recipe as IRecipeModel);
}
return _medicineRecipes;
}
}
[ForeignKey("MedicineId")]
public virtual List<RecipeMedicine> Recipes { get; set; } = new();
[ForeignKey("MedicineId")]
public virtual List<ProcedureMedicine> Services { get; set; } = new();
public static Medicine Create(HospitalDatabase context,
MedicineBindingModel model)
{
return new Medicine()
{
Id = model.Id,
Name = model.Name,
Price = model.Price,
Recipes = model.MedicineRecipes.Select(x => new
RecipeMedicine
{
Recipe = context.Recipes.First(y => y.Id == x.Key),
}).ToList(),
PharmacistId = model.PharmacistId,
Pharmacist = context.Pharmacists.First(x => x.Id == model.PharmacistId)
};
}
public void Update(MedicineBindingModel model)
{
Name = model.Name;
Price = model.Price;
}
public MedicineViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Price = Price,
MedicineRecipes = MedicineRecipes,
};
public void UpdateRecipes(HospitalDatabase context,
MedicineBindingModel model)
{
if (model.MedicineRecipes == null)
return;
var medicineRecipes = context.RecipeMedicines.Where(rec =>
rec.MedicineId == model.Id).ToList();
if (medicineRecipes != null && medicineRecipes.Count > 0)
{
context.RecipeMedicines.RemoveRange(medicineRecipes.Where(rec
=> !model.MedicineRecipes.ContainsKey(rec.RecipeId)));
foreach (var recipe in medicineRecipes)
{
model.MedicineRecipes.Remove(recipe.RecipeId);
}
context.SaveChanges();
}
var medicine = context.Medicines.First(x => x.Id == Id);
foreach (var pc in model.MedicineRecipes)
{
context.RecipeMedicines.Add(new RecipeMedicine
{
Medicine = medicine,
Recipe = context.Recipes.First(x => x.Id == pc.Key),
});
context.SaveChanges();
}
_medicineRecipes = null;
}
}
}

View File

@ -0,0 +1,134 @@
using HospitalContracts.BindingModels;
using HospitalContracts.ViewModels;
using HospitalDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDatabaseImplement.Models
{
public class Patient : IPatientModel
{
public int Id { get; set; }
[Required]
public int DoctorId { get; private set; }
public virtual Doctor Doctor { get; set; }
[Required]
[MaxLength(50)]
public string FIO { get; set; } = string.Empty;
[Required]
[MaxLength(50)]
public string Address { get; set; } = string.Empty;
[Required]
public DateTime BirthDate { get; set; }
private Dictionary<int, IRecipeModel>? _patientRecipes = null;
[ForeignKey("PatientId")]
public virtual List<PatientProcedure> Procedures { get; set; } = new();
[ForeignKey("PatientId")]
public virtual List<PatientRecipe> Recipes { get; set; } = new();
/*[NotMapped]
public Dictionary<int, IRecipeModel> PatientRecipes
{
get
{
if (_patientRecipes == null)
{
_patientRecipes = Recipes.ToDictionary(recPR => recPR.RecipeId, recPR => (recPR.Recipe as IRecipeModel));
}
return _patientRecipes;
}
}*/
private Dictionary<int, IProcedureModel>? _patientProcedures = null;
[NotMapped]
public Dictionary<int, IProcedureModel> PatientProcedures
{
get
{
if (_patientProcedures == null)
{
_patientProcedures = Procedures.ToDictionary(recPP => recPP.ProcedureId, recPP => (recPP.Procedure as IProcedureModel));
}
return _patientProcedures;
}
}
public static Patient Create(HospitalDatabase context, PatientBindingModel model)
{
return new Patient()
{
// Id = model.Id,
FIO = model.FIO,
Address = model.Address,
BirthDate = model.BirthDate,
DoctorId = model.DoctorId,
Doctor = context.Doctors.First(x => x.Id == model.DoctorId),
Procedures = model.PatientProcedures.Select(x => new PatientProcedure
{
Procedure = context.Procedures.First(y => y.Id == x.Key),
}).ToList()
};
}
public void Update(PatientBindingModel model)
{
FIO = model.FIO;
Address = model.Address;
BirthDate = model.BirthDate;
}
public PatientViewModel GetViewModel => new()
{
FIO = FIO,
Address = Address,
BirthDate = BirthDate,
PatientProcedures = PatientProcedures
};
public void UpdateProcedures(HospitalDatabase context, PatientBindingModel model)
{
var servicePatients = context.PatientProcedures.Where(rec => rec.PatientId == model.Id).ToList();
if (servicePatients != null)
{ // удалили те, которых нет в модели
context.PatientProcedures.RemoveRange(servicePatients.Where(rec => !model.PatientProcedures.ContainsKey(rec.ProcedureId)));
context.SaveChanges();
foreach (var service in servicePatients)
{
model.PatientProcedures.Remove(service.ProcedureId);
}
context.SaveChanges();
}
var visit = context.Patients.First(x => x.Id == Id);
foreach (var pc in model.PatientProcedures)
{
context.PatientProcedures.Add(new PatientProcedure
{
Patient = visit,
Procedure = context.Procedures.First(x => x.Id == pc.Key),
});
context.SaveChanges();
}
_patientProcedures = null;
}
}
}

View File

@ -0,0 +1,25 @@
using HospitalDatabaseImplement.Modelss;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDatabaseImplement.Models
{
public class PatientProcedure
{
public int Id { get; set; }
[Required]
public int PatientId { get; set; }
[Required]
public int ProcedureId { get; set; }
public virtual Patient Patient { get; set; } = new();
public virtual Procedure Procedure { get; set; } = new();
}
}

View File

@ -0,0 +1,26 @@
using HospitalDatabaseImplement.Modelss;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDatabaseImplement.Models
{
public class PatientRecipe
{
public int Id { get; set; }
[Required]
public int PatientId { get; set; }
[Required]
public int RecipeId { get; set; }
public virtual Patient Patient { get; set; } = new();
public virtual Recipe Recipe { get; set; } = new();
}
}

View File

@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using HospitalContracts.BindingModels;
using HospitalContracts.ViewModels;
using HospitalDataModels.Models;
using HospitalDatabaseImplement.Models;
namespace HospitalDatabaseImplement.Models
{
public class Pharmacist : IPharmacistModel
{
public int Id { get; set; }
[Required]
[MaxLength(25)]
public string Login { get; set; } = string.Empty;
[Required]
[MaxLength(55)]
public string FIO { get; set; } = string.Empty;
[Required]
[MaxLength(11)]
public string PhoneNumber { get; set; } = string.Empty;
[Required]
[MaxLength(30)]
public string Password { get; set; } = string.Empty;
[ForeignKey("PharmacistId")]
public virtual List<Medicine> Medicines { get; set; } = new();
[ForeignKey("PharmacistId")]
public virtual List<Procedure> Procedures { get; set; } = new();
[ForeignKey("PharmacistId")]
public virtual List<DescriptionProcedure> DescriptionProcedures { get; set; } = new();
public static Pharmacist? Create(PharmacistBindingModel model)
{
if (model == null)
{
return null;
}
return new Pharmacist()
{
Id = model.Id,
Login = model.Login,
PhoneNumber = model.PhoneNumber,
Password = model.Password
};
}
public static Pharmacist Create(PharmacistViewModel model)
{
return new Pharmacist
{
Id = model.Id,
Login = model.Login,
PhoneNumber = model.PhoneNumber,
Password = model.Password
};
}
public void Update(PharmacistBindingModel model)
{
if (model == null)
{
return;
}
Login = model.Login;
PhoneNumber = model.PhoneNumber;
Password = model.Password;
}
public PharmacistViewModel GetViewModel => new()
{
Id = Id,
Login = Login,
PhoneNumber = PhoneNumber,
Password = Password
};
}
}

View File

@ -0,0 +1,105 @@
using HospitalContracts.BindingModels;
using HospitalContracts.ViewModels;
using HospitalDatabaseImplement.Models;
using HospitalDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalDatabaseImplement.Modelss;
namespace HospitalDatabaseImplement.Models
{
public class Procedure : IProcedureModel
{
public int Id { get; set; }
[Required]
[MaxLength(50)]
public string Name { get; set; } = string.Empty;
[ForeignKey("ProcedureId")]
public virtual List<PatientProcedure> PatientProcedures { get; set; } = new();
private Dictionary<int, IMedicineModel>? _procedureMedicines = null;
[NotMapped]
public Dictionary<int, IMedicineModel> ProcedureMedicines
{
get
{
if (_procedureMedicines == null)
{
_procedureMedicines = Medicines.ToDictionary(recPM => recPM.MedicineId, recPM => (recPM.Medicine as IMedicineModel));
}
return _procedureMedicines;
}
}
[ForeignKey("ProcedureId")]
public virtual List<ProcedureMedicine> Medicines { get; set; } = new();
public static Procedure Create(HospitalDatabase context, ProcedureBindingModel model)
{
return new Procedure()
{
Id = model.Id,
Name = model.Name,
Medicines = model.ProcedureMedicines.Select(x => new ProcedureMedicine
{
Medicine = context.Medicines.First(y => y.Id == x.Key)
}).ToList()
};
}
public void Update(ProcedureBindingModel model)
{
Name = model.Name;
}
public ProcedureViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
ProcedureMedicines = ProcedureMedicines
};
[Required]
public DateTime Date { get; set; }
[Required]
public int DescriptionProcedureId { get; set; }
public virtual DescriptionProcedure DescriptionProcedure { get; set; }
public int PharmacistId { get; private set; }
public virtual Pharmacist Pharmacist { get; set; }
public void UpdateMedicines(HospitalDatabase context, ProcedureBindingModel model)
{
var procedureMedicines = context.ProcedureMedicines.Where(rec => rec.ProcedureId == model.Id).ToList();
if (procedureMedicines != null)
{ // удалили те, которых нет в модели
context.ProcedureMedicines.RemoveRange(procedureMedicines.Where(rec => !model.ProcedureMedicines.ContainsKey(rec.MedicineId)));
context.SaveChanges();
}
var procedure = context.Procedures.First(x => x.Id == Id);
foreach (var pm in model.ProcedureMedicines)
{
context.ProcedureMedicines.Add(new ProcedureMedicine
{
Procedure = procedure,
Medicine = context.Medicines.First(x => x.Id == pm.Key)
});
context.SaveChanges();
}
_procedureMedicines = null;
}
}
}

View File

@ -0,0 +1,25 @@
using HospitalDatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDatabaseImplement.Models
{
public class ProcedureMedicine
{
public int Id { get; set; }
[Required]
public int ProcedureId { get; set; }
[Required]
public int MedicineId { get; set; }
public virtual Procedure Procedure { get; set; } = new();
public virtual Medicine Medicine { get; set; } = new();
}
}

View File

@ -0,0 +1,102 @@
using HospitalContracts.BindingModels;
using HospitalContracts.ViewModels;
using HospitalDatabaseImplement.Models;
using HospitalDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDatabaseImplement.Modelss
{
public class Recipe : IRecipeModel
{
public int Id { get; set; }
public int DoctorId { get; private set; }
public virtual Doctor Doctor { get; set; }
public int DiseaseId { get; private set; }
public virtual Disease Disease { get; set; }
[Required]
public DateTime IssueDate { get; private set; } = DateTime.Now;
[Required]
public string Description { get; private set; } = string.Empty;
private Dictionary<int, IPatientModel>? _recipePatients = null;
[NotMapped]
public Dictionary<int, IPatientModel> RecipePatients
{
get
{
if (_recipePatients == null)
{
_recipePatients = Patients.ToDictionary(recRM => recRM.PatientId, recRM => (recRM.Patient as IPatientModel));
}
return _recipePatients;
}
}
[ForeignKey("RecipeId")]
public virtual List<PatientRecipe> Patients { get; set; } = new();
public static Recipe Create(HospitalDatabase context, RecipeBindingModel model)
{
return new Recipe()
{
//Id = model.Id,
IssueDate = model.IssueDate,
Description = model.Description,
DiseaseId = model.DiseaseId,
DoctorId = model.DoctorId,
Doctor = context.Doctors.First(x => x.Id == model.DoctorId),
Patients = model.RecipePatients.Select(x => new PatientRecipe
{
Patient = context.Patients.First(y => y.Id == x.Key),
}).ToList()
};
}
public void Update(RecipeBindingModel model)
{
IssueDate = model.IssueDate;
Description = model.Description;
}
public RecipeViewModel GetViewModel => new()
{
Id = Id,
IssueDate = IssueDate,
RecipePatients = RecipePatients
};
public void UpdatePatients(HospitalDatabase context, RecipeBindingModel model)
{
var recipePatients = context.PatientRecipes.Where(rec => rec.RecipeId == model.Id).ToList();
if (recipePatients != null)
{ // удалили те, которых нет в модели
context.PatientRecipes.RemoveRange(recipePatients.Where(rec => !model.RecipePatients.ContainsKey(rec.PatientId)));
context.SaveChanges();
}
var recipe = context.Recipes.First(x => x.Id == Id);
foreach (var pr in model.RecipePatients)
{
context.PatientRecipes.Add(new PatientRecipe
{
Recipe = recipe,
Patient = context.Patients.First(x => x.Id == pr.Key),
});
context.SaveChanges();
}
_recipePatients = null;
}
}
}

View File

@ -0,0 +1,25 @@
using HospitalDatabaseImplement.Modelss;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDatabaseImplement.Models
{
public class RecipeMedicine
{
public int Id { get; set; }
[Required]
public int RecipeId { get; set; }
[Required]
public int MedicineId { get; set; }
public virtual Recipe Recipe { get; set; } = new();
public virtual Medicine Medicine { get; set; } = new();
}
}

View File

@ -0,0 +1,52 @@
using System.Net.Http.Headers;
using System.Text;
using HospitalContracts.ViewModels;
using Newtonsoft.Json;
namespace HospitalDoctorApp
{
public class APIClient
{
private static readonly HttpClient _doctor = new();
public static DoctorViewModel? Doctor { get; set; } = null;
public static void Connect(IConfiguration configuration)
{
_doctor.BaseAddress = new Uri(configuration["IPAddress"]);
_doctor.DefaultRequestHeaders.Accept.Clear();
_doctor.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
public static T? GetRequest<T>(string requestUrl)
{
var response = _doctor.GetAsync(requestUrl);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (response.Result.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject<T>(result);
}
else
{
throw new Exception(result);
}
}
public static void PostRequest<T>(string requestUrl, T model)
{
var json = JsonConvert.SerializeObject(model);
var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = _doctor.PostAsync(requestUrl, data);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (!response.Result.IsSuccessStatusCode)
{
throw new Exception(result);
}
}
}
}

View File

@ -0,0 +1,535 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using HospitalDataModels.Models;
using HospitalDoctorApp.Models;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
namespace HospitalDoctorApp.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
public IActionResult Index()
{
if (APIClient.Doctor == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<PatientViewModel>>($"api/patient/getpatients?doctorId={APIClient.Doctor.Id}"));
}
public IActionResult IndexRecipes()
{
if (APIClient.Doctor == null)
{
return Redirect("~/Home/Enter");
}
return
View(APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doctorId={APIClient.Doctor.Id}"));
}
public IActionResult IndexDiseases()
{
if (APIClient.Doctor == null)
{
return Redirect("~/Home/Enter");
}
return
View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?diseaseId={APIClient.Doctor.Id}"));
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
#region Вход и регистрация
[HttpGet]
public IActionResult Register()
{
return View();
}
[HttpGet]
public IActionResult Privacy()
{
if (APIClient.Doctor == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.Doctor);
}
[HttpGet]
public IActionResult Enter()
{
return View();
}
[HttpPost]
public void Privacy(string login, string email, string password, string fio, string telephone)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
{
throw new Exception("Введите логин, пароль и ФИО");
}
APIClient.PostRequest("api/doctor/updatedata", new DoctorBindingModel
{
Id = APIClient.Doctor.Id,
FIO = fio,
Login = login,
Password = password,
MailAddress = email,
PhoneNumber = telephone
});
APIClient.Doctor.FIO = fio;
APIClient.Doctor.Login = login;
APIClient.Doctor.Password = password;
APIClient.Doctor.MailAddress = email;
APIClient.Doctor.PhoneNumber = telephone;
Response.Redirect("Index");
}
[HttpPost]
public void Register(string login, string email, string password, string fio, string telephone)
{
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
{
throw new Exception("Введите логин, пароль и ФИО");
}
APIClient.PostRequest("api/doctor/register", new DoctorBindingModel
{
FIO = fio,
Login = login,
Password = password,
MailAddress = email,
PhoneNumber = telephone
});
Response.Redirect("Enter");
return;
}
[HttpPost]
public void Enter(string login, string password)
{
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
{
throw new Exception("Введите логин и пароль");
}
APIClient.Doctor = APIClient.GetRequest<DoctorViewModel>($"api/doctor/login?login={login}&password={password}");
if (APIClient.Doctor == null)
{
throw new Exception("Неверный логин/пароль");
}
Response.Redirect("Index");
}
#endregion
#region Создание
public IActionResult CreatePatient()
{
if (APIClient.Doctor == null)
{
return Redirect("~/Home/");
}
return View();
}
public IActionResult CreateRecipe()
{
if (APIClient.Doctor == null)
{
return Redirect("~/Home/");
}
return View();
}
public IActionResult CreateDisease()
{
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>("api/recipe/getrecipelist");
return View();
}
[HttpPost]
public void CreatePatient(string name, string address, DateTime patientdate)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(address))
{
throw new Exception("Ошибка в введенных данных");
}
APIClient.PostRequest("api/patient/createpatient", new PatientBindingModel
{
FIO = name,
BirthDate = patientdate,
Address = address,
DoctorId = APIClient.Doctor.Id
});
Response.Redirect("Index");
}
[HttpPost]
public void CreateRecipe(string description, DateTime issueDate)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
if (string.IsNullOrEmpty(description))
{
throw new Exception("Ошибка в введенных данных");
}
APIClient.PostRequest("api/recipe/createrecipe", new RecipeBindingModel
{
Description = description,
IssueDate = issueDate,
DoctorId = APIClient.Doctor.Id
});
Response.Redirect("IndexRecipes");
}
[HttpPost]
public void CreateDisease(int doctorId, string name, string description)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
if (string.IsNullOrEmpty(name))
{
throw new Exception("Ошибка в введенных данных");
}
if (string.IsNullOrEmpty(description))
{
throw new Exception("Ошибка в введенных данных");
}
APIClient.PostRequest("api/disease/createdisease", new DiseaseBindingModel
{
Name = name,
DoctorId = doctorId,
Description = description
});
Response.Redirect("IndexDiseases");
}
#endregion
#region Удаление
public IActionResult DeletePatient()
{
if (APIClient.Doctor == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Patients = APIClient.GetRequest<List<PatientViewModel>>("api/patient/getpatients");
return View();
}
[HttpPost]
public void DeletePatient(int patient)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
APIClient.PostRequest("api/patient/deletepatient", new PatientBindingModel
{
Id = patient
});
Response.Redirect("Index");
}
public IActionResult DeleteRecipe()
{
if (APIClient.Doctor == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doctorid={APIClient.Doctor.Id}");
return View();
}
public IActionResult DeleteDisease()
{
if (APIClient.Doctor == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Diseases = APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?doctorid={APIClient.Doctor.Id}");
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)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
APIClient.PostRequest("api/disease/deletedisease", new DiseaseBindingModel
{
Id = disease
});
Response.Redirect("IndexDiseases");
}
#endregion
#region Обновление
public IActionResult UpdatePatient()
{
if (APIClient.Doctor == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Patients = APIClient.GetRequest<List<PatientViewModel>>("api/patient/getpatients");
return View();
}
[HttpPost]
public void UpdatePatient(int patient, string name, string address, DateTime birthdate)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
if (string.IsNullOrEmpty(name))
{
throw new Exception("Ошибка в введенных данных");
}
APIClient.PostRequest("api/patient/updatepatient", new PatientBindingModel
{
Id = patient,
FIO = name,
Address = address,
BirthDate = birthdate,
});
Response.Redirect("Index");
}
public IActionResult UpdateRecipe()
{
if (APIClient.Doctor == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doctorid={APIClient.Doctor.Id}");
return View();
}
[HttpPost]
public void UpdateRecipe(int recipe, string description, DateTime issuedate)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
if (string.IsNullOrEmpty(description))
{
throw new Exception("Ошибка в введенных данных");
}
APIClient.PostRequest("api/recipe/updaterecipe", new RecipeBindingModel
{
Id = recipe,
Description = description,
IssueDate = issuedate
});
Response.Redirect("IndexRecipes");
}
public IActionResult UpdateDisease()
{
if (APIClient.Doctor == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Diseases = APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?doctorid={APIClient.Doctor.Id}");
return View();
}
[HttpPost]
public void UpdateDisease(int disease, string description, string name)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
if (string.IsNullOrEmpty(description))
{
throw new Exception("Ошибка в введенных данных");
}
APIClient.PostRequest("api/disease/updatedisease", new DiseaseBindingModel
{
Id = disease,
Name = name,
Description = description,
});
Response.Redirect("IndexDisease");
}
#endregion
#region Промежуточные таблицы
public IActionResult PatientRecipes()
{
if (APIClient.Doctor == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doctorid={APIClient.Doctor.Id}");
ViewBag.Patients = APIClient.GetRequest<List<PatientViewModel>>($"api/patient/getpatients");
return View();
}
[HttpPost]
public void PatientRecipes(int recipe, string description, DateTime date,
List<int> patients)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
if (string.IsNullOrEmpty(description))
{
throw new Exception("Ошибка в введенных данных");
}
Dictionary<int, IPatientModel> v = new Dictionary<int, IPatientModel>();
foreach (int patient in patients)
{
v.Add(patient, new PatientSearchModel { Id = patient } as IPatientModel);
}
APIClient.PostRequest("api/recipe/updaterecipe?isconnection=true", new RecipeBindingModel
{
Id = recipe,
Description = description,
IssueDate = date,
DoctorId = APIClient.Doctor.Id,
RecipePatients = v
});
Response.Redirect("IndexRecipes");
}
public IActionResult ProcedurePatients()
{
if (APIClient.Doctor == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Patients = APIClient.GetRequest<List<PatientViewModel>>($"api/patient/getpatients?doctorid={APIClient.Doctor.Id}");
ViewBag.Procedures = APIClient.GetRequest<List<ProcedureViewModel>>($"api/procedure/getprocedures");
return View();
}
[HttpPost]
public void ProcedurePatients(int patient, string name, DateTime date,
List<int> procedures)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
if (string.IsNullOrEmpty(name) || date == new DateTime())
{
throw new Exception("Ошибка в введенных данных");
}
Dictionary<int, IProcedureModel> s = new Dictionary<int, IProcedureModel>();
foreach (int procedure in procedures)
{
s.Add(procedure, new ProcedureSearchModel { Id = procedure } as IProcedureModel);
}
APIClient.PostRequest("api/patient/updatepatient?isconnection=true", new PatientBindingModel
{
Id = patient,
FIO = name,
BirthDate = date,
DoctorId = APIClient.Doctor.Id,
PatientProcedures = s
});
Response.Redirect("Index");
}
#endregion
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[HttpGet]
public Tuple<PatientViewModel, List<string>>? GetPatient(int patientId)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
var result = APIClient.GetRequest<Tuple<PatientViewModel, List<string>>>($"api/patient/getpatient?patientid={patientId}");
if (result == null)
{
return default;
}
return result;
}
[HttpGet]
public Tuple<RecipeViewModel, List<string>>? GetRecipe(int recipeId)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
var result = APIClient.GetRequest<Tuple<RecipeViewModel, List<string>>>($"api/recipe/getrecipe?recipeid={recipeId}");
if (result == null)
{
return default;
}
return result;
}
[HttpGet]
public Tuple<ProcedureViewModel, List<string>>? GetProcedure(int procedureId)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
var result = APIClient.GetRequest<Tuple<ProcedureViewModel, List<string>>>($"api/procedure/getprocedure?procedureid={procedureId}");
if (result == null)
{
return default;
}
return result;
}
}
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HospitalContracts\HospitalContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,9 @@
namespace HospitalDoctorApp.Models
{
public class ErrorViewModel
{
public string? RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}

View File

@ -0,0 +1,29 @@
using HospitalDoctorApp;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
var app = builder.Build();
APIClient.Connect(builder.Configuration);
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();

View File

@ -0,0 +1,28 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:22150",
"sslPort": 44369
}
},
"profiles": {
"HospitalDoctorApp": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7242;http://localhost:5089",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,28 @@
@{
ViewData["Title"] = "CreateDisease";
}
<head>
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
</head>
<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>

View File

@ -0,0 +1,28 @@
@{
ViewData["Title"] = "CreateDisease";
}
<head>
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
</head>
<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>

Some files were not shown because too many files have changed in this diff Show More