Compare commits
46 Commits
b92099c257
...
c9e51c422a
Author | SHA1 | Date | |
---|---|---|---|
c9e51c422a | |||
2df3afc00e | |||
|
d0cc63abfe | ||
|
5c8b768dc1 | ||
|
050762b81d | ||
18295f78b9 | |||
cf75520b70 | |||
52f5e5a1e3 | |||
|
c0d0b68892 | ||
|
38196534b9 | ||
|
0054d6550a | ||
549fb1ec23 | |||
30ea05901a | |||
c43bf6c66d | |||
01996f74f1 | |||
0b87bc8287 | |||
|
df2127107f | ||
9a10ad410d | |||
ced335c941 | |||
5e0f6fd0be | |||
f2041b026e | |||
b65e364788 | |||
|
b5c19360c8 | ||
|
e12f96bb3e | ||
|
9e8c7b46d2 | ||
575e573a38 | |||
|
6654a1b627 | ||
|
910e0d374e | ||
|
8745ef65a8 | ||
|
7b81211711 | ||
|
00ed5959f0 | ||
|
c5c0273831 | ||
e4dd335a12 | |||
|
cc1edf7a7d | ||
|
086679ff89 | ||
|
139333ed95 | ||
|
17756e6991 | ||
|
da083000b1 | ||
|
1ea63f1588 | ||
|
c0058315ee | ||
|
7629dc561b | ||
aab75401ba | |||
181c9a1181 | |||
cb3b32509c | |||
e9185fa7dc | |||
2de477b1cc |
@ -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
|
||||
|
@ -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>
|
12
Hospital/Hospital/Properties/launchSettings.json
Normal file
12
Hospital/Hospital/Properties/launchSettings.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"profiles": {
|
||||
"HospitalView": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:51159;http://localhost:51164"
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
115
Hospital/HospitalBusinessLogic/BusinessLogics/DiseaseLogic.cs
Normal file
115
Hospital/HospitalBusinessLogic/BusinessLogics/DiseaseLogic.cs
Normal 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("Болезнь с такими данными уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
124
Hospital/HospitalBusinessLogic/BusinessLogics/DoctorLogic.cs
Normal file
124
Hospital/HospitalBusinessLogic/BusinessLogics/DoctorLogic.cs
Normal 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("Врач с таким именем уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
Hospital/HospitalBusinessLogic/BusinessLogics/MedicineLogic.cs
Normal file
120
Hospital/HospitalBusinessLogic/BusinessLogics/MedicineLogic.cs
Normal 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("Медикамент с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
Hospital/HospitalBusinessLogic/BusinessLogics/PatientLogic.cs
Normal file
120
Hospital/HospitalBusinessLogic/BusinessLogics/PatientLogic.cs
Normal 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("Пациент с такими данными уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
127
Hospital/HospitalBusinessLogic/BusinessLogics/PharmacistLogic.cs
Normal file
127
Hospital/HospitalBusinessLogic/BusinessLogics/PharmacistLogic.cs
Normal 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("Клиент с таким логином уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
120
Hospital/HospitalBusinessLogic/BusinessLogics/ProcedureLogic.cs
Normal file
120
Hospital/HospitalBusinessLogic/BusinessLogics/ProcedureLogic.cs
Normal 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("Услуга с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
115
Hospital/HospitalBusinessLogic/BusinessLogics/RecipeLogic.cs
Normal file
115
Hospital/HospitalBusinessLogic/BusinessLogics/RecipeLogic.cs
Normal 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("Пациент с такими данными уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
18
Hospital/HospitalBusinessLogic/HospitalBusinessLogic.csproj
Normal file
18
Hospital/HospitalBusinessLogic/HospitalBusinessLogic.csproj
Normal 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>
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"profiles": {
|
||||
"HospitalBusinessLogic": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:51157;http://localhost:51163"
|
||||
}
|
||||
}
|
||||
}
|
@ -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; }
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
@ -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; }
|
||||
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
13
Hospital/HospitalContracts/HospitalContracts.csproj
Normal file
13
Hospital/HospitalContracts/HospitalContracts.csproj
Normal 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>
|
12
Hospital/HospitalContracts/Properties/launchSettings.json
Normal file
12
Hospital/HospitalContracts/Properties/launchSettings.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"profiles": {
|
||||
"HospitalContracts": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:51160;http://localhost:51162"
|
||||
}
|
||||
}
|
||||
}
|
@ -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; }
|
||||
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
18
Hospital/HospitalContracts/SearchModels/DoctorSearchModel.cs
Normal file
18
Hospital/HospitalContracts/SearchModels/DoctorSearchModel.cs
Normal 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; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
|
||||
}
|
||||
}
|
16
Hospital/HospitalContracts/SearchModels/RecipeSearchModel.cs
Normal file
16
Hospital/HospitalContracts/SearchModels/RecipeSearchModel.cs
Normal 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; }
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
|
||||
|
||||
}
|
||||
}
|
22
Hospital/HospitalContracts/ViewModels/DiseaseViewModel.cs
Normal file
22
Hospital/HospitalContracts/ViewModels/DiseaseViewModel.cs
Normal 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; }
|
||||
}
|
||||
}
|
30
Hospital/HospitalContracts/ViewModels/DoctorViewModel.cs
Normal file
30
Hospital/HospitalContracts/ViewModels/DoctorViewModel.cs
Normal 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;
|
||||
}
|
||||
}
|
27
Hospital/HospitalContracts/ViewModels/MedicineViewModel.cs
Normal file
27
Hospital/HospitalContracts/ViewModels/MedicineViewModel.cs
Normal 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();
|
||||
|
||||
}
|
||||
}
|
32
Hospital/HospitalContracts/ViewModels/PatientViewModel.cs
Normal file
32
Hospital/HospitalContracts/ViewModels/PatientViewModel.cs
Normal 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();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
23
Hospital/HospitalContracts/ViewModels/PharmacistViewModel.cs
Normal file
23
Hospital/HospitalContracts/ViewModels/PharmacistViewModel.cs
Normal 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;
|
||||
}
|
||||
}
|
26
Hospital/HospitalContracts/ViewModels/ProcedureViewModel.cs
Normal file
26
Hospital/HospitalContracts/ViewModels/ProcedureViewModel.cs
Normal 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();
|
||||
|
||||
}
|
||||
}
|
25
Hospital/HospitalContracts/ViewModels/RecipeViewModel.cs
Normal file
25
Hospital/HospitalContracts/ViewModels/RecipeViewModel.cs
Normal 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();
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -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>
|
46
Hospital/HospitalDataBaseImplement/HospitalDatabase.cs
Normal file
46
Hospital/HospitalDataBaseImplement/HospitalDatabase.cs
Normal 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; }
|
||||
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"profiles": {
|
||||
"HospitalDatabaseImplement": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:51158;http://localhost:51165"
|
||||
}
|
||||
}
|
||||
}
|
15
Hospital/HospitalDataModels/HospitalDataModels.csproj
Normal file
15
Hospital/HospitalDataModels/HospitalDataModels.csproj
Normal 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>
|
7
Hospital/HospitalDataModels/IId.cs
Normal file
7
Hospital/HospitalDataModels/IId.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace HospitalDataModels
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
|
||||
}
|
||||
}
|
15
Hospital/HospitalDataModels/Models/IDiseaseModel.cs
Normal file
15
Hospital/HospitalDataModels/Models/IDiseaseModel.cs
Normal 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; }
|
||||
}
|
||||
}
|
18
Hospital/HospitalDataModels/Models/IDoctorModel.cs
Normal file
18
Hospital/HospitalDataModels/Models/IDoctorModel.cs
Normal 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; }
|
||||
}
|
||||
}
|
18
Hospital/HospitalDataModels/Models/IMedicineModel.cs
Normal file
18
Hospital/HospitalDataModels/Models/IMedicineModel.cs
Normal 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; }
|
||||
|
||||
}
|
||||
}
|
18
Hospital/HospitalDataModels/Models/IPatientModel.cs
Normal file
18
Hospital/HospitalDataModels/Models/IPatientModel.cs
Normal 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; }
|
||||
|
||||
}
|
||||
}
|
17
Hospital/HospitalDataModels/Models/IPharmacistModel.cs
Normal file
17
Hospital/HospitalDataModels/Models/IPharmacistModel.cs
Normal 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; }
|
||||
}
|
||||
}
|
21
Hospital/HospitalDataModels/Models/IProcedureModel.cs
Normal file
21
Hospital/HospitalDataModels/Models/IProcedureModel.cs
Normal 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; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
21
Hospital/HospitalDataModels/Models/IRecipeModel.cs
Normal file
21
Hospital/HospitalDataModels/Models/IRecipeModel.cs
Normal 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; }
|
||||
}
|
||||
}
|
12
Hospital/HospitalDataModels/Properties/launchSettings.json
Normal file
12
Hospital/HospitalDataModels/Properties/launchSettings.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"profiles": {
|
||||
"HospitalDataModels": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:51161;http://localhost:51166"
|
||||
}
|
||||
}
|
||||
}
|
120
Hospital/HospitalDatabaseImplement/Implementss/DiseaseStorage.cs
Normal file
120
Hospital/HospitalDatabaseImplement/Implementss/DiseaseStorage.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
114
Hospital/HospitalDatabaseImplement/Implementss/DoctorStorage.cs
Normal file
114
Hospital/HospitalDatabaseImplement/Implementss/DoctorStorage.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
122
Hospital/HospitalDatabaseImplement/Implementss/PatientStorage.cs
Normal file
122
Hospital/HospitalDatabaseImplement/Implementss/PatientStorage.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
123
Hospital/HospitalDatabaseImplement/Implementss/RecipeStorage.cs
Normal file
123
Hospital/HospitalDatabaseImplement/Implementss/RecipeStorage.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
581
Hospital/HospitalDatabaseImplement/Migrations/20240430102720_InitCreate.Designer.cs
generated
Normal file
581
Hospital/HospitalDatabaseImplement/Migrations/20240430102720_InitCreate.Designer.cs
generated
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
77
Hospital/HospitalDatabaseImplement/Models/Disease.cs
Normal file
77
Hospital/HospitalDatabaseImplement/Models/Disease.cs
Normal 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
|
||||
};
|
||||
}
|
||||
}
|
98
Hospital/HospitalDatabaseImplement/Models/Doctor.cs
Normal file
98
Hospital/HospitalDatabaseImplement/Models/Doctor.cs
Normal 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
|
||||
};
|
||||
}
|
||||
}
|
114
Hospital/HospitalDatabaseImplement/Models/Medicine.cs
Normal file
114
Hospital/HospitalDatabaseImplement/Models/Medicine.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
134
Hospital/HospitalDatabaseImplement/Models/Patient.cs
Normal file
134
Hospital/HospitalDatabaseImplement/Models/Patient.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
26
Hospital/HospitalDatabaseImplement/Models/PatientRecipe.cs
Normal file
26
Hospital/HospitalDatabaseImplement/Models/PatientRecipe.cs
Normal 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();
|
||||
|
||||
}
|
||||
}
|
85
Hospital/HospitalDatabaseImplement/Models/Pharmacist.cs
Normal file
85
Hospital/HospitalDatabaseImplement/Models/Pharmacist.cs
Normal 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
|
||||
};
|
||||
}
|
||||
}
|
105
Hospital/HospitalDatabaseImplement/Models/Procedure.cs
Normal file
105
Hospital/HospitalDatabaseImplement/Models/Procedure.cs
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
102
Hospital/HospitalDatabaseImplement/Models/Recipe.cs
Normal file
102
Hospital/HospitalDatabaseImplement/Models/Recipe.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
25
Hospital/HospitalDatabaseImplement/Models/RecipeMedicine.cs
Normal file
25
Hospital/HospitalDatabaseImplement/Models/RecipeMedicine.cs
Normal 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();
|
||||
}
|
||||
}
|
52
Hospital/HospitalDoctorApp/APIClient.cs
Normal file
52
Hospital/HospitalDoctorApp/APIClient.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
535
Hospital/HospitalDoctorApp/Controllers/HomeController.cs
Normal file
535
Hospital/HospitalDoctorApp/Controllers/HomeController.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
17
Hospital/HospitalDoctorApp/HospitalDoctorApp.csproj
Normal file
17
Hospital/HospitalDoctorApp/HospitalDoctorApp.csproj
Normal 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>
|
9
Hospital/HospitalDoctorApp/Models/ErrorViewModel.cs
Normal file
9
Hospital/HospitalDoctorApp/Models/ErrorViewModel.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace HospitalDoctorApp.Models
|
||||
{
|
||||
public class ErrorViewModel
|
||||
{
|
||||
public string? RequestId { get; set; }
|
||||
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
}
|
||||
}
|
29
Hospital/HospitalDoctorApp/Program.cs
Normal file
29
Hospital/HospitalDoctorApp/Program.cs
Normal 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();
|
28
Hospital/HospitalDoctorApp/Properties/launchSettings.json
Normal file
28
Hospital/HospitalDoctorApp/Properties/launchSettings.json
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
28
Hospital/HospitalDoctorApp/Views/Home/CreateDisease.cshtml
Normal file
28
Hospital/HospitalDoctorApp/Views/Home/CreateDisease.cshtml
Normal 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
Loading…
Reference in New Issue
Block a user