Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
HIAST-Clinics
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
almohanad.hafez
HIAST-Clinics
Commits
ead3c9e3
Unverified
Commit
ead3c9e3
authored
Aug 17, 2024
by
Almouhannad Hafez
Committed by
GitHub
Aug 17, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4 from Almouhannad/B_Refactoring-domain
B refactoring domain
parents
5d8df969
fe7a2b72
Changes
39
Show whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
2197 additions
and
75 deletions
+2197
-75
Program.cs
Clinics.Backend/API/Program.cs
+7
-0
Disease.cs
Clinics.Backend/Domain/Entities/Medicals/Diseases/Disease.cs
+30
-2
Hospital.cs
...cs.Backend/Domain/Entities/Medicals/Hospitals/Hospital.cs
+27
-2
MedicalImage.cs
...nd/Domain/Entities/Medicals/MedicalImages/MedicalImage.cs
+26
-2
MedicalTest.cs
...kend/Domain/Entities/Medicals/MedicalTests/MedicalTest.cs
+26
-2
Medicine.cs
...cs.Backend/Domain/Entities/Medicals/Medicines/Medicine.cs
+53
-2
MedicineForm.cs
...ies/Medicals/Medicines/MedicineFormValues/MedicineForm.cs
+33
-2
MedicineForms.cs
...es/Medicals/Medicines/MedicineFormValues/MedicineForms.cs
+2
-2
Doctor.cs
Clinics.Backend/Domain/Entities/People/Doctors/Doctor.cs
+66
-2
DoctorStatus.cs
...ctors/Shared/Constants/DoctorStatusValues/DoctorStatus.cs
+0
-12
DoctorPhone.cs
...kend/Domain/Entities/People/Doctors/Shared/DoctorPhone.cs
+28
-2
DoctorStatus.cs
.../People/Doctors/Shared/DoctorStatusValues/DoctorStatus.cs
+45
-0
DoctorStatuses.cs
...eople/Doctors/Shared/DoctorStatusValues/DoctorStatuses.cs
+14
-0
Employee.cs
Clinics.Backend/Domain/Entities/People/Employees/Employee.cs
+112
-5
EmployeeFamilyMember.cs
...s/Relations/EmployeeFamilyMembers/EmployeeFamilyMember.cs
+52
-1
FamilyRole.cs
...ions/EmployeeFamilyMembers/FamilyRoleValues/FamilyRole.cs
+35
-2
FamilyRoles.cs
...ons/EmployeeFamilyMembers/FamilyRoleValues/FamilyRoles.cs
+4
-4
EmployeeAdditionalInfo.cs
...ntities/People/Employees/Shared/EmployeeAdditionalInfo.cs
+47
-1
FamilyMember.cs
...kend/Domain/Entities/People/FamilyMembers/FamilyMember.cs
+39
-1
Patient.cs
Clinics.Backend/Domain/Entities/People/Patients/Patient.cs
+132
-8
PatientDisease.cs
...ople/Patients/Relations/PatientDiseases/PatientDisease.cs
+26
-1
PatientMedicine.cs
...le/Patients/Relations/PatientMedicines/PatientMedicine.cs
+30
-1
Gender.cs
...kend/Domain/Entities/People/Shared/GenderValues/Gender.cs
+37
-3
Genders.cs
...end/Domain/Entities/People/Shared/GenderValues/Genders.cs
+2
-2
PersonalInfo.cs
...ics.Backend/Domain/Entities/People/Shared/PersonalInfo.cs
+40
-5
VisitMedicalImage.cs
.../Visits/Relations/VisitMedicalImages/VisitMedicalImage.cs
+40
-1
VisitMedicalTest.cs
...es/Visits/Relations/VisitMedicalTests/VisitMedicalTest.cs
+41
-1
VisitMedicine.cs
...Entities/Visits/Relations/VisitMedicines/VisitMedicine.cs
+29
-1
Visit.cs
Clinics.Backend/Domain/Entities/Visits/Visit.cs
+133
-5
WaitingListRecord.cs
....Backend/Domain/Entities/WaitingList/WaitingListRecord.cs
+37
-1
DomainException.cs
Clinics.Backend/Domain/Exceptions/Base/DomainException.cs
+9
-0
InvalidValuesDomainException.cs
...n/Exceptions/InvalidValue/InvalidValuesDomainException.cs
+13
-0
PatientConfiguration.cs
...ce/Configurations/People/Patients/PatientConfiguration.cs
+3
-0
PersonalInfoConfiguration.cs
...Configurations/People/Shared/PersonalInfoConfiguration.cs
+4
-0
VisitConfiguration.cs
...d/Persistence/Configurations/Visits/VisitConfiguration.cs
+2
-0
20240816173549_Add_Amount_To_Medicine.Designer.cs
...rations/20240816173549_Add_Amount_To_Medicine.Designer.cs
+937
-0
20240816173549_Add_Amount_To_Medicine.cs
...tence/Migrations/20240816173549_Add_Amount_To_Medicine.cs
+29
-0
ClinicsDbContextModelSnapshot.cs
...d/Persistence/Migrations/ClinicsDbContextModelSnapshot.cs
+3
-0
Repositroy.cs
Clinics.Backend/Persistence/Repositories/Base/Repositroy.cs
+4
-2
No files found.
Clinics.Backend/API/Program.cs
View file @
ead3c9e3
using
API.Options.Database
;
using
Domain.Repositories.Base
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.Extensions.Options
;
using
Persistence.Context
;
using
Persistence.Repositories.Base
;
var
builder
=
WebApplication
.
CreateBuilder
(
args
);
...
...
@@ -30,6 +32,11 @@ builder.Services.AddDbContext<ClinicsDbContext>(
// Add services to the container.
#region Link repositories
// AddTransient: Created on demand, every time they are requested, not shared across requests or components.
builder
.
Services
.
AddTransient
(
typeof
(
IRepository
<>),
typeof
(
Repositroy
<>));
#endregion
#region Link controllers with presentation layer
var
presentationAssembly
=
typeof
(
Presentation
.
AssemblyReference
).
Assembly
;
builder
.
Services
.
AddControllers
()
...
...
Clinics.Backend/Domain/Entities/Medicals/Diseases/Disease.cs
View file @
ead3c9e3
using
Domain.Entities.People.Patients.Relations.PatientDiseases
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.Medicals.Diseases
;
public
sealed
class
Disease
(
int
id
)
:
Entity
(
id
)
public
sealed
class
Disease
:
Entity
{
#
region
Private
ctor
private
Disease
(
int
id
)
:
base
(
id
)
{
}
private
Disease
(
int
id
,
string
name
)
:
base
(
id
)
{
Name
=
name
;
}
#
endregion
#
region
Properties
public
string
Name
{
get
;
set
;
}
=
null
!;
#
region
Navigations
public
ICollection
<
PatientDisease
>
Patients
{
get
;
set
;
}
=
[];
#
region
Patients
private
readonly
List
<
PatientDisease
>
_patients
=
[];
public
IReadOnlyCollection
<
PatientDisease
>
Patients
=>
_patients
;
#
endregion
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
Disease
Create
(
string
name
)
{
if
(
name
is
null
)
throw
new
InvalidValuesDomainException
<
Disease
>();
return
new
Disease
(
0
,
name
);
}
#
endregion
#
endregion
...
...
Clinics.Backend/Domain/Entities/Medicals/Hospitals/Hospital.cs
View file @
ead3c9e3
using
Domain.Primitives
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.Medicals.Hospitals
;
public
sealed
class
Hospital
(
int
id
)
:
Entity
(
id
)
public
sealed
class
Hospital
:
Entity
{
#
region
Private
ctor
private
Hospital
(
int
id
)
:
base
(
id
)
{
}
private
Hospital
(
int
id
,
string
name
)
:
base
(
id
)
{
Name
=
name
;
}
#
endregion
#
region
Properties
public
string
Name
{
get
;
set
;
}
=
null
!;
#
endregion
#
region
Methods
#
region
Static
factory
public
static
Hospital
Create
(
string
name
)
{
if
(
name
is
null
)
throw
new
InvalidValuesDomainException
<
Hospital
>();
return
new
Hospital
(
0
,
name
);
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/Medicals/MedicalImages/MedicalImage.cs
View file @
ead3c9e3
using
Domain.Primitives
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.Medicals.MedicalImages
;
public
sealed
class
MedicalImage
(
int
id
)
:
Entity
(
id
)
public
sealed
class
MedicalImage
:
Entity
{
#
region
Private
ctor
private
MedicalImage
(
int
id
)
:
base
(
id
)
{
}
private
MedicalImage
(
int
id
,
string
name
,
string
?
description
=
null
)
:
base
(
id
)
{
Name
=
name
;
Description
=
description
;
}
#
endregion
#
region
Properties
public
string
Name
{
get
;
set
;
}
=
null
!;
...
...
@@ -11,4 +22,17 @@ public sealed class MedicalImage(int id) : Entity(id)
public
string
?
Description
{
get
;
set
;
}
#
endregion
#
region
Methods
#
region
Static
factory
public
static
MedicalImage
Create
(
string
name
,
string
?
description
=
null
)
{
if
(
name
is
null
)
throw
new
InvalidValuesDomainException
<
MedicalImage
>();
return
new
MedicalImage
(
0
,
name
,
description
);
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/Medicals/MedicalTests/MedicalTest.cs
View file @
ead3c9e3
using
Domain.Primitives
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.Medicals.MedicalTests
;
public
sealed
class
MedicalTest
(
int
id
)
:
Entity
(
id
)
public
sealed
class
MedicalTest
:
Entity
{
#
region
Private
ctor
private
MedicalTest
(
int
id
)
:
base
(
id
)
{
}
private
MedicalTest
(
int
id
,
string
name
,
string
?
description
=
null
)
:
base
(
id
)
{
Name
=
name
;
Description
=
description
;
}
#
endregion
#
region
Properties
public
string
Name
{
get
;
set
;
}
=
null
!;
...
...
@@ -11,4 +22,17 @@ public sealed class MedicalTest(int id) : Entity(id)
public
string
?
Description
{
get
;
set
;
}
#
endregion
#
region
Methods
#
region
Static
factory
public
static
MedicalTest
Create
(
string
name
,
string
description
)
{
if
(
name
is
null
)
throw
new
InvalidValuesDomainException
<
MedicalTest
>();
return
new
MedicalTest
(
0
,
name
,
description
);
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/Medicals/Medicines/Medicine.cs
View file @
ead3c9e3
using
Domain.Entities.Medicals.Medicines.MedicineFormValues
;
using
Domain.Entities.People.Patients.Relations.PatientMedicines
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.Medicals.Medicines
;
// TODO: Convert Dosage to value object
public
sealed
class
Medicine
(
int
id
)
:
Entity
(
id
)
public
sealed
class
Medicine
:
Entity
{
#
region
Private
ctor
private
Medicine
(
int
id
)
:
base
(
id
)
{
}
private
Medicine
(
int
id
,
MedicineForm
medicineForm
,
int
amount
,
string
name
,
decimal
dosage
)
:
base
(
id
)
{
MedicineForm
=
medicineForm
;
Amount
=
amount
;
Name
=
name
;
Dosage
=
dosage
;
}
#
endregion
#
region
Properties
public
MedicineForm
MedicineForm
{
get
;
set
;
}
=
null
!;
public
int
Amount
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
=
null
!;
public
decimal
Dosage
{
get
;
set
;
}
#
region
Navigations
public
ICollection
<
PatientMedicine
>
Patients
{
get
;
set
;
}
=
[];
#
region
Patients
private
readonly
List
<
PatientMedicine
>
_patients
=
[];
public
IReadOnlyCollection
<
PatientMedicine
>
Patients
=>
_patients
;
#
endregion
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
Medicine
Create
(
string
form
,
int
amount
,
string
name
,
decimal
dosage
)
{
if
(
form
is
null
||
name
is
null
||
amount
<
0
||
dosage
<
0
)
throw
new
InvalidValuesDomainException
<
Medicine
>();
#
region
Check
form
MedicineForm
selectedMedicineForm
;
MedicineForm
tablet
=
MedicineForms
.
Tablet
;
MedicineForm
syrup
=
MedicineForms
.
Syrup
;
if
(
form
==
tablet
.
Name
)
selectedMedicineForm
=
tablet
;
else
if
(
form
==
syrup
.
Name
)
selectedMedicineForm
=
syrup
;
else
throw
new
InvalidValuesDomainException
<
MedicineForm
>();
#
endregion
return
new
Medicine
(
0
,
selectedMedicineForm
,
amount
,
name
,
dosage
);
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/Medicals/Medicines/MedicineFormValues/MedicineForm.cs
View file @
ead3c9e3
using
Domain.Primitives
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.Medicals.Medicines.MedicineFormValues
;
public
sealed
class
MedicineForm
(
int
id
)
:
Entity
(
id
)
public
sealed
class
MedicineForm
:
Entity
{
#
region
Private
ctor
private
MedicineForm
(
int
id
)
:
base
(
id
)
{
}
private
MedicineForm
(
int
id
,
string
name
)
:
base
(
id
)
{
Name
=
name
;
}
#
endregion
#
region
Properties
public
string
Name
{
get
;
set
;
}
=
null
!;
#
endregion
#
region
Methods
#
region
Static
factory
public
static
MedicineForm
Create
(
string
name
,
int
?
id
)
{
if
(
name
is
null
)
throw
new
InvalidValuesDomainException
<
MedicineForm
>();
if
(
id
is
not
null
)
{
if
(
id
<
0
)
throw
new
InvalidValuesDomainException
<
MedicineForm
>();
return
new
MedicineForm
(
id
.
Value
,
name
);
}
return
new
MedicineForm
(
0
,
name
);
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/Medicals/Medicines/MedicineFormValues/MedicineForms.cs
View file @
ead3c9e3
...
...
@@ -4,9 +4,9 @@ public static class MedicineForms
{
#
region
Constant
id
values
public
static
int
Tablet
=>
1
;
public
static
MedicineForm
Tablet
=>
MedicineForm
.
Create
(
"حبوب"
,
1
)
;
public
static
int
Syrup
=>
2
;
public
static
MedicineForm
Syrup
=>
MedicineForm
.
Create
(
"شراب"
,
2
)
;
#
endregion
}
Clinics.Backend/Domain/Entities/People/Doctors/Doctor.cs
View file @
ead3c9e3
using
Domain.Entities.People.Doctors.Shared
;
using
Domain.Entities.People.Doctors.Shared.Constants.DoctorStatusValues
;
using
Domain.Entities.People.Shared
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.People.Doctors
;
public
sealed
class
Doctor
(
int
id
)
:
Entity
(
id
)
public
sealed
class
Doctor
:
Entity
{
#
region
Private
ctor
private
Doctor
(
int
id
)
:
base
(
id
)
{
}
private
Doctor
(
int
id
,
PersonalInfo
personalInfo
)
:
base
(
id
)
{
PersonalInfo
=
personalInfo
;
Status
=
DoctorStatuses
.
Available
;
}
#
endregion
#
region
Properties
public
PersonalInfo
PersonalInfo
{
get
;
set
;
}
=
null
!;
...
...
@@ -15,8 +28,59 @@ public sealed class Doctor(int id) : Entity(id)
#
region
Navigations
public
ICollection
<
DoctorPhone
>
Phones
{
get
;
set
;
}
=
[];
#
region
Phones
private
readonly
List
<
DoctorPhone
>
_phones
=
[];
public
IReadOnlyCollection
<
DoctorPhone
>
Phones
=>
_phones
;
#
endregion
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
Doctor
Create
(
string
firstName
,
string
middleName
,
string
lastName
)
{
PersonalInfo
personalInfo
;
try
{
personalInfo
=
PersonalInfo
.
Create
(
firstName
,
middleName
,
lastName
);
}
catch
{
throw
;
}
return
new
Doctor
(
0
,
personalInfo
);
}
#
endregion
#
region
Add
phone
public
void
AddPhone
(
string
phone
,
string
?
number
=
null
)
{
DoctorPhone
doctorPhone
;
try
{
doctorPhone
=
DoctorPhone
.
Create
(
phone
,
number
);
}
catch
{
throw
;
}
_phones
.
Add
(
doctorPhone
);
}
#
endregion
#
region
Change
status
public
void
ChangeStatusTo
(
DoctorStatus
status
)
{
if
(
status
==
DoctorStatuses
.
Available
||
status
==
DoctorStatuses
.
Busy
||
status
==
DoctorStatuses
.
Working
)
Status
=
status
;
throw
new
InvalidValuesDomainException
<
DoctorStatus
>();
}
#
endregion
#
endregion
...
...
Clinics.Backend/Domain/Entities/People/Doctors/Shared/Constants/DoctorStatusValues/DoctorStatus.cs
deleted
100644 → 0
View file @
5d8df969
using
Domain.Primitives
;
namespace
Domain.Entities.People.Doctors.Shared.Constants.DoctorStatusValues
;
public
sealed
class
DoctorStatus
(
int
id
)
:
Entity
(
id
)
{
#
region
Properties
public
string
Name
{
get
;
set
;
}
=
null
!;
#
endregion
}
Clinics.Backend/Domain/Entities/People/Doctors/Shared/DoctorPhone.cs
View file @
ead3c9e3
using
Domain.Primitives
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.People.Doctors.Shared
;
// TODO: Convert phone property to a value object
public
sealed
class
DoctorPhone
(
int
id
)
:
Entity
(
id
)
public
sealed
class
DoctorPhone
:
Entity
{
#
region
Private
ctor
private
DoctorPhone
(
int
id
)
:
base
(
id
)
{
}
private
DoctorPhone
(
int
id
,
string
phone
,
string
?
name
=
null
)
:
base
(
id
)
{
Phone
=
phone
;
Name
=
name
;
}
#
endregion
#
region
Properties
public
string
?
Name
{
get
;
set
;
}
...
...
@@ -12,4 +23,19 @@ public sealed class DoctorPhone(int id) : Entity(id)
public
string
Phone
{
get
;
set
;
}
=
null
!;
#
endregion
#
region
Methods
#
region
Static
factory
public
static
DoctorPhone
Create
(
string
phone
,
string
?
name
)
{
if
(
phone
is
null
)
throw
new
InvalidValuesDomainException
<
DoctorPhone
>();
return
new
DoctorPhone
(
0
,
phone
,
name
);
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/People/Doctors/Shared/DoctorStatusValues/DoctorStatus.cs
0 → 100644
View file @
ead3c9e3
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.People.Doctors.Shared.Constants.DoctorStatusValues
;
public
sealed
class
DoctorStatus
:
Entity
{
#
region
Private
ctor
private
DoctorStatus
(
int
id
)
:
base
(
id
)
{
}
private
DoctorStatus
(
int
id
,
string
name
)
:
base
(
id
)
{
Name
=
name
;
}
#
endregion
#
region
Properties
public
string
Name
{
get
;
set
;
}
=
null
!;
#
endregion
#
region
Methods
#
region
Static
factory
public
static
DoctorStatus
Create
(
string
name
,
int
?
id
)
{
if
(
name
is
null
)
throw
new
InvalidValuesDomainException
<
DoctorStatus
>();
if
(
id
is
not
null
)
{
if
(
id
<
0
)
throw
new
InvalidValuesDomainException
<
DoctorStatus
>();
return
new
DoctorStatus
(
id
.
Value
,
name
);
}
return
new
DoctorStatus
(
0
,
name
);
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/People/Doctors/Shared/
Constants/
DoctorStatusValues/DoctorStatuses.cs
→
Clinics.Backend/Domain/Entities/People/Doctors/Shared/DoctorStatusValues/DoctorStatuses.cs
View file @
ead3c9e3
...
...
@@ -4,11 +4,11 @@ public static class DoctorStatuses
{
#
region
Constant
id
values
public
static
int
Available
=>
1
;
public
static
DoctorStatus
Available
=>
DoctorStatus
.
Create
(
"متاح"
,
1
)
;
public
static
int
Working
=>
2
;
public
static
DoctorStatus
Working
=>
DoctorStatus
.
Create
(
"لديه مريض"
,
1
)
;
public
static
int
Busy
=>
3
;
public
static
DoctorStatus
Busy
=>
DoctorStatus
.
Create
(
"مشغول"
,
1
)
;
#
endregion
}
Clinics.Backend/Domain/Entities/People/Employees/Employee.cs
View file @
ead3c9e3
using
Domain.Entities.People.Employees.Relations.EmployeeFamilyMembers
;
using
Domain.Entities.People.Employees.Shared
;
using
Domain.Entities.People.FamilyMembers
;
using
Domain.Entities.People.Patients
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.People.Employees
;
public
sealed
class
Employee
(
int
id
)
:
Entity
(
id
)
public
sealed
class
Employee
:
Entity
{
#
region
Private
ctor
private
Employee
(
int
id
)
:
base
(
id
)
{
}
private
Employee
(
int
id
,
Patient
patient
,
string
serialNumber
,
string
centerStatus
,
bool
isMarried
=
false
,
EmployeeAdditionalInfo
?
additionalInfo
=
null
)
:
base
(
id
)
{
Patient
=
patient
;
SerialNumber
=
serialNumber
;
CenterStatus
=
centerStatus
;
IsMarried
=
isMarried
;
AdditionalInfo
=
additionalInfo
;
}
#
endregion
#
region
Properties
public
Patient
Patient
{
get
;
set
;
}
=
null
!;
...
...
@@ -17,16 +38,102 @@ public sealed class Employee(int id) : Entity(id)
public
string
CenterStatus
{
get
;
set
;
}
=
null
!;
public
bool
IsMarried
{
get
;
set
;
}
=
false
;
public
bool
IsMarried
{
get
;
set
;
}
#
region
Navigations
public
ICollection
<
EmployeeFamilyMember
>
FamilyMembers
{
get
;
set
;
}
=
[];
#
region
Family
members
private
readonly
List
<
EmployeeFamilyMember
>
_familyMembers
=
[];
public
IReadOnlyCollection
<
EmployeeFamilyMember
>
FamilyMembers
=>
_familyMembers
;
#
endregion
#
region
Related
employees
private
readonly
List
<
Employee
>
_relatedEmployees
=
[];
public
IReadOnlyCollection
<
Employee
>
RelatedEmployees
=>
_relatedEmployees
;
private
readonly
List
<
Employee
>
_relatedTo
=
[];
public
IReadOnlyCollection
<
Employee
>
RelatedTo
=>
_relatedTo
;
#
endregion
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
Employee
Create
(
string
firstName
,
string
middleName
,
string
lastName
,
DateOnly
dateOfBirth
,
string
gender
,
string
serialNumber
,
string
centerStatus
,
bool
isMarried
=
false
,
DateOnly
?
startDate
=
null
,
string
?
academicQualification
=
null
,
string
?
workPhone
=
null
,
string
?
location
=
null
,
string
?
specialization
=
null
,
string
?
jobStatus
=
null
,
string
?
imageUrl
=
null
)
{
#
region
Create
patient
Patient
patient
;
try
{
patient
=
Patient
.
Create
(
firstName
,
middleName
,
lastName
,
dateOfBirth
,
gender
);
}
catch
{
throw
;
}
#
endregion
#
region
Check
employee
'
s
required
details
if
(
serialNumber
is
null
||
centerStatus
is
null
)
throw
new
InvalidValuesDomainException
<
Employee
>();
public
ICollection
<
Employee
>
RelatedEmployees
{
get
;
set
;
}
=
[];
#
endregion
#
region
Create
additional
info
EmployeeAdditionalInfo
additionalInfo
;
try
{
additionalInfo
=
EmployeeAdditionalInfo
.
Create
(
startDate
,
academicQualification
,
workPhone
,
location
,
specialization
,
jobStatus
,
imageUrl
);
}
catch
{
throw
;
}
#
endregion
public
ICollection
<
Employee
>
RelatedTo
{
get
;
set
;
}
=
[];
return
new
Employee
(
0
,
patient
,
serialNumber
,
centerStatus
,
isMarried
,
additionalInfo
);
}
#
endregion
#
region
Add
family
member
public
void
AddFamilyMember
(
FamilyMember
familyMember
,
string
role
)
{
EmployeeFamilyMember
employeeFamilyMember
;
try
{
employeeFamilyMember
=
EmployeeFamilyMember
.
Create
(
Id
,
familyMember
.
Id
,
role
);
}
catch
{
throw
;
}
_familyMembers
.
Add
(
employeeFamilyMember
);
}
#
endregion
#
region
Add
related
employee
public
void
AddRelatedEmployee
(
Employee
employee
)
{
_relatedEmployees
.
Add
(
employee
);
}
#
endregion
#
endregion
...
...
Clinics.Backend/Domain/Entities/People/Employees/Relations/EmployeeFamilyMembers/EmployeeFamilyMember.cs
View file @
ead3c9e3
using
Domain.Entities.People.Employees.Relations.EmployeeFamilyMembers.FamilyRoleValues
;
using
Domain.Entities.People.FamilyMembers
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.People.Employees.Relations.EmployeeFamilyMembers
;
public
sealed
class
EmployeeFamilyMember
(
int
id
)
:
Entity
(
id
)
public
sealed
class
EmployeeFamilyMember
:
Entity
{
#
region
Private
ctor
private
EmployeeFamilyMember
(
int
id
)
:
base
(
id
)
{
}
private
EmployeeFamilyMember
(
int
id
,
int
employeeId
,
int
familyMemberId
,
FamilyRole
role
)
:
base
(
id
)
{
EmployeeId
=
employeeId
;
FamilyMemberId
=
familyMemberId
;
Role
=
role
;
}
#
endregion
#
region
Properties
#
region
Employee
...
...
@@ -29,4 +42,42 @@ public sealed class EmployeeFamilyMember(int id) : Entity(id)
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
EmployeeFamilyMember
Create
(
int
employeeId
,
int
familyMemberId
,
string
role
)
{
if
(
employeeId
<=
0
||
familyMemberId
<=
0
||
role
is
null
)
throw
new
InvalidValuesDomainException
<
EmployeeFamilyMember
>();
#
region
Check
role
FamilyRole
?
selectedRole
;
FamilyRole
husband
=
FamilyRoles
.
Husband
;
FamilyRole
wife
=
FamilyRoles
.
Wife
;
FamilyRole
son
=
FamilyRoles
.
Son
;
FamilyRole
daughter
=
FamilyRoles
.
Daughter
;
if
(
role
==
husband
.
Name
)
selectedRole
=
husband
;
else
if
(
role
==
wife
.
Name
)
selectedRole
=
wife
;
else
if
(
role
==
son
.
Name
)
selectedRole
=
son
;
else
if
(
role
==
daughter
.
Name
)
selectedRole
=
daughter
;
else
selectedRole
=
null
;
if
(
selectedRole
is
null
)
throw
new
InvalidValuesDomainException
<
FamilyRole
>();
#
endregion
return
new
EmployeeFamilyMember
(
0
,
employeeId
,
familyMemberId
,
selectedRole
);
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/People/Employees/Relations/EmployeeFamilyMembers/FamilyRoleValues/FamilyRole.cs
View file @
ead3c9e3
using
Domain.Primitives
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.People.Employees.Relations.EmployeeFamilyMembers.FamilyRoleValues
;
public
sealed
class
FamilyRole
(
int
id
)
:
Entity
(
id
)
public
sealed
class
FamilyRole
:
Entity
{
#
region
Private
ctor
private
FamilyRole
(
int
id
)
:
base
(
id
)
{
}
private
FamilyRole
(
int
id
,
string
name
)
:
base
(
id
)
{
Name
=
name
;
}
#
endregion
#
region
Properties
public
string
Name
{
get
;
set
;
}
=
null
!;
#
endregion
#
region
Methods
#
region
Static
factory
public
static
FamilyRole
Create
(
string
name
,
int
?
id
)
{
if
(
name
is
null
)
throw
new
InvalidValuesDomainException
<
FamilyRole
>();
if
(
id
is
not
null
)
{
if
(
id
<
0
)
throw
new
InvalidValuesDomainException
<
FamilyRole
>();
return
new
FamilyRole
(
id
.
Value
,
name
);
}
return
new
FamilyRole
(
0
,
name
);
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/People/Employees/Relations/EmployeeFamilyMembers/FamilyRoleValues/FamilyRoles.cs
View file @
ead3c9e3
...
...
@@ -4,13 +4,13 @@ public static class FamilyRoles
{
#
region
Constant
id
values
public
static
int
Husband
=>
1
;
public
static
FamilyRole
Husband
=>
FamilyRole
.
Create
(
"زوج"
,
1
)
;
public
static
int
Wife
=>
2
;
public
static
FamilyRole
Wife
=>
FamilyRole
.
Create
(
"زوجة"
,
2
)
;
public
static
int
Son
=>
3
;
public
static
FamilyRole
Son
=>
FamilyRole
.
Create
(
"ابن"
,
3
)
;
public
static
int
Daughter
=>
4
;
public
static
FamilyRole
Daughter
=>
FamilyRole
.
Create
(
"ابنة"
,
4
)
;
#
endregion
}
Clinics.Backend/Domain/Entities/People/Employees/Shared/EmployeeAdditionalInfo.cs
View file @
ead3c9e3
...
...
@@ -3,8 +3,36 @@
namespace
Domain.Entities.People.Employees.Shared
;
// TODO: Convert to a value object containig value objects
public
sealed
class
EmployeeAdditionalInfo
(
int
id
)
:
Entity
(
id
)
public
sealed
class
EmployeeAdditionalInfo
:
Entity
{
#
region
Private
ctor
private
EmployeeAdditionalInfo
(
int
id
)
:
base
(
id
)
{
}
private
EmployeeAdditionalInfo
(
int
id
,
DateOnly
?
startDate
,
string
?
academicQualification
,
string
?
workPhone
,
string
?
location
,
string
?
specialization
,
string
?
jobStatus
,
string
?
imageUrl
)
:
base
(
id
)
{
StartDate
=
startDate
;
AcademicQualification
=
academicQualification
;
WorkPhone
=
workPhone
;
Location
=
location
;
Specialization
=
specialization
;
JobStatus
=
jobStatus
;
ImageUrl
=
imageUrl
;
}
#
endregion
#
region
Properties
public
DateOnly
?
StartDate
{
get
;
set
;
}
...
...
@@ -22,4 +50,22 @@ public sealed class EmployeeAdditionalInfo(int id) : Entity(id)
public
string
?
ImageUrl
{
get
;
set
;
}
#
endregion
#
region
Methods
#
region
Static
factory
public
static
EmployeeAdditionalInfo
Create
(
DateOnly
?
startDate
,
string
?
academicQualification
,
string
?
workPhone
,
string
?
location
,
string
?
specialization
,
string
?
jobStatus
,
string
?
imageUrl
)
{
return
new
EmployeeAdditionalInfo
(
0
,
startDate
,
academicQualification
,
workPhone
,
location
,
specialization
,
jobStatus
,
imageUrl
);
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/People/FamilyMembers/FamilyMember.cs
View file @
ead3c9e3
...
...
@@ -3,11 +3,49 @@ using Domain.Primitives;
namespace
Domain.Entities.People.FamilyMembers
;
public
sealed
class
FamilyMember
(
int
id
)
:
Entity
(
id
)
public
sealed
class
FamilyMember
:
Entity
{
#
region
Private
ctor
private
FamilyMember
(
int
id
)
:
base
(
id
)
{
}
private
FamilyMember
(
int
id
,
Patient
patient
)
:
base
(
id
)
{
Patient
=
patient
;
}
#
endregion
#
region
Properties
public
Patient
Patient
{
get
;
set
;
}
=
null
!;
#
endregion
#
region
Methods
#
region
Static
factory
public
static
FamilyMember
Create
(
string
firstName
,
string
middleName
,
string
lastName
,
DateOnly
dateOfBirth
,
string
gender
)
{
#
region
Create
patient
Patient
patient
;
try
{
patient
=
Patient
.
Create
(
firstName
,
middleName
,
lastName
,
dateOfBirth
,
gender
);
}
catch
{
throw
;
}
#
endregion
return
new
FamilyMember
(
0
,
patient
);
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/People/Patients/Patient.cs
View file @
ead3c9e3
using
Domain.Entities.People.Patients.Relations.PatientDiseases
;
using
Domain.Entities.Medicals.Diseases
;
using
Domain.Entities.Medicals.Medicines
;
using
Domain.Entities.People.Patients.Relations.PatientDiseases
;
using
Domain.Entities.People.Patients.Relations.PatientMedicines
;
using
Domain.Entities.People.Shared
;
using
Domain.Entities.People.Shared.GenderValues
;
using
Domain.Entities.Visits
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.People.Patients
;
// TODO: Potential aggregate?
public
sealed
class
Patient
(
int
id
)
:
Entity
(
id
)
public
sealed
class
Patient
:
Entity
{
#
region
Private
ctor
private
Patient
(
int
id
)
:
base
(
id
)
{
}
private
Patient
(
int
id
,
PersonalInfo
personalInfo
,
DateOnly
dateOfBirth
,
Gender
gender
)
:
base
(
id
)
{
PersonalInfo
=
personalInfo
;
DateOfBirth
=
dateOfBirth
;
Gender
=
gender
;
}
#
endregion
#
region
Properties
public
PersonalInfo
PersonalInfo
{
get
;
set
;
}
=
null
!;
public
PersonalInfo
PersonalInfo
{
get
;
private
set
;
}
=
null
!;
public
DateOnly
DateOfBirth
{
get
;
set
;
}
public
DateOnly
DateOfBirth
{
get
;
private
set
;
}
public
Gender
Gender
{
get
;
set
;
}
=
null
!;
public
int
Age
{
get
{
var
today
=
DateOnly
.
FromDateTime
(
DateTime
.
Today
);
var
age
=
today
.
Year
-
DateOfBirth
.
Year
;
if
(
today
.
Month
<
DateOfBirth
.
Month
||
(
today
.
Month
==
DateOfBirth
.
Month
&&
today
.
Day
<
DateOfBirth
.
Day
))
{
age
--;
}
return
age
;
}
}
public
Gender
Gender
{
get
;
private
set
;
}
=
null
!;
#
region
Navigations
public
ICollection
<
PatientDisease
>
Diseases
{
get
;
set
;
}
=
[];
#
region
Diseases
private
readonly
List
<
PatientDisease
>
_diseases
=
[];
public
IReadOnlyCollection
<
PatientDisease
>
Diseases
=>
_diseases
;
#
endregion
#
region
Medicines
private
readonly
List
<
PatientMedicine
>
_medicines
=
[];
public
IReadOnlyCollection
<
PatientMedicine
>
Medicines
=>
_medicines
;
#
endregion
#
region
Visits
private
readonly
List
<
Visit
>
_visits
=
[];
public
IReadOnlyCollection
<
Visit
>
Visits
=>
_visits
;
#
endregion
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
Patient
Create
(
string
firstName
,
string
middleName
,
string
lastName
,
DateOnly
dateOfBirth
,
string
gender
)
{
#
region
Personal
info
PersonalInfo
?
personalInfo
;
try
{
personalInfo
=
PersonalInfo
.
Create
(
firstName
,
middleName
,
lastName
);
}
catch
{
throw
;
}
#
endregion
#
region
Gender
if
(
gender
is
null
)
throw
new
InvalidValuesDomainException
<
Gender
>();
Gender
?
selectedGender
;
Gender
male
=
Genders
.
Male
;
Gender
female
=
Genders
.
Female
;
if
(
gender
==
male
.
Name
)
selectedGender
=
male
;
else
if
(
gender
==
female
.
Name
)
selectedGender
=
female
;
else
selectedGender
=
null
;
public
ICollection
<
PatientMedicine
>
Medicines
{
get
;
set
;
}
=
[];
if
(
selectedGender
is
null
)
throw
new
InvalidValuesDomainException
<
Gender
>();
#
endregion
return
new
Patient
(
0
,
personalInfo
,
dateOfBirth
,
selectedGender
);
}
#
endregion
#
region
Add
medicine
public
void
AddMedicine
(
Medicine
medicine
,
int
number
)
{
PatientMedicine
entry
;
try
{
entry
=
PatientMedicine
.
Create
(
Id
,
medicine
.
Id
,
number
);
}
catch
{
throw
;
}
_medicines
.
Add
(
entry
);
}
#
endregion
public
ICollection
<
Visit
>
Visits
{
get
;
set
;
}
=
[];
#
region
Add
disease
public
void
AddDisease
(
Disease
disease
)
{
PatientDisease
entry
;
try
{
entry
=
PatientDisease
.
Create
(
Id
,
disease
.
Id
);
}
catch
{
throw
;
}
_diseases
.
Add
(
entry
);
}
#
endregion
#
endregion
...
...
Clinics.Backend/Domain/Entities/People/Patients/Relations/PatientDiseases/PatientDisease.cs
View file @
ead3c9e3
using
Domain.Entities.Medicals.Diseases
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.People.Patients.Relations.PatientDiseases
;
public
sealed
class
PatientDisease
(
int
id
)
:
Entity
(
id
)
public
sealed
class
PatientDisease
:
Entity
{
#
region
Private
ctor
private
PatientDisease
(
int
id
)
:
base
(
id
)
{
}
private
PatientDisease
(
int
id
,
int
patientId
,
int
diseaseId
)
:
base
(
id
)
{
PatientId
=
patientId
;
DiseaseId
=
diseaseId
;
}
#
endregion
#
region
Properties
...
...
@@ -27,4 +39,17 @@ public sealed class PatientDisease(int id) : Entity(id)
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
PatientDisease
Create
(
int
patientId
,
int
diseaseId
)
{
if
(
patientId
<=
0
||
diseaseId
<=
0
)
throw
new
InvalidValuesDomainException
<
PatientDisease
>();
return
new
PatientDisease
(
0
,
patientId
,
diseaseId
);
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/People/Patients/Relations/PatientMedicines/PatientMedicine.cs
View file @
ead3c9e3
using
Domain.Entities.Medicals.Medicines
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.People.Patients.Relations.PatientMedicines
;
public
sealed
class
PatientMedicine
(
int
id
)
:
Entity
(
id
)
public
sealed
class
PatientMedicine
:
Entity
{
#
region
Private
ctor
private
PatientMedicine
(
int
id
)
:
base
(
id
)
{
}
private
PatientMedicine
(
int
id
,
int
patientId
,
int
medicineId
,
int
number
)
:
base
(
id
)
{
PatientId
=
patientId
;
MedicineId
=
medicineId
;
Number
=
number
;
}
#
endregion
#
region
Properties
#
region
Patient
...
...
@@ -28,5 +44,18 @@ public sealed class PatientMedicine(int id) : Entity(id)
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
PatientMedicine
Create
(
int
patientId
,
int
medicineId
,
int
number
)
{
if
(
patientId
<=
0
||
medicineId
<=
0
||
number
<=
0
)
throw
new
InvalidValuesDomainException
<
PatientMedicine
>();
return
new
PatientMedicine
(
0
,
patientId
,
medicineId
,
number
);
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/People/Shared/GenderValues/Gender.cs
View file @
ead3c9e3
using
Domain.Primitives
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.People.Shared.GenderValues
;
// TODO: Convert to a value object
public
sealed
class
Gender
(
int
id
)
:
Entity
(
id
)
public
sealed
class
Gender
:
Entity
{
#
region
Private
ctor
private
Gender
(
int
id
)
:
base
(
id
)
{
}
private
Gender
(
int
id
,
string
name
)
:
base
(
id
)
{
Name
=
name
;
}
#
endregion
#
region
Properties
public
string
Name
{
get
;
set
;
}
=
null
!;
public
string
Name
{
get
;
private
set
;
}
=
null
!;
#
endregion
#
region
Methods
#
region
Static
factory
public
static
Gender
Create
(
string
name
,
int
?
id
)
{
if
(
name
is
null
)
throw
new
InvalidValuesDomainException
<
Gender
>();
if
(
id
is
not
null
)
{
if
(
id
<
0
)
throw
new
InvalidValuesDomainException
<
Gender
>();
return
new
Gender
(
id
.
Value
,
name
);
}
return
new
Gender
(
0
,
name
);
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/People/Shared/GenderValues/Genders.cs
View file @
ead3c9e3
...
...
@@ -4,9 +4,9 @@ public static class Genders
{
#
region
Constant
id
values
public
static
int
Male
=>
1
;
public
static
Gender
Male
=>
Gender
.
Create
(
"ذكر"
,
1
)
;
public
static
int
Female
=>
2
;
public
static
Gender
Female
=>
Gender
.
Create
(
"أنثى"
,
2
)
;
#
endregion
}
Clinics.Backend/Domain/Entities/People/Shared/PersonalInfo.cs
View file @
ead3c9e3
using
Domain.Primitives
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.People.Shared
;
// TODO: Convert props to value objects
public
sealed
class
PersonalInfo
(
int
id
)
:
Entity
(
id
)
public
sealed
class
PersonalInfo
:
Entity
{
#
region
Private
ctor
private
PersonalInfo
(
int
id
)
:
base
(
id
)
{
}
private
PersonalInfo
(
int
id
,
string
firstName
,
string
middleName
,
string
lastName
)
:
base
(
id
)
{
FirstName
=
firstName
;
MiddleName
=
middleName
;
LastName
=
lastName
;
}
#
endregion
#
region
Properties
public
string
FirstName
{
get
;
set
;
}
=
null
!;
public
string
FirstName
{
get
;
private
set
;
}
=
null
!;
public
string
MiddleName
{
get
;
private
set
;
}
=
null
!;
public
string
MiddleName
{
get
;
set
;
}
=
null
!;
public
string
LastName
{
get
;
private
set
;
}
=
null
!;
public
string
LastName
{
get
;
set
;
}
=
null
!;
public
string
FullName
{
get
{
return
$"
{
FirstName
}
{
MiddleName
}
{
LastName
}
"
;
}
}
#
endregion
#
region
Methods
#
region
Static
factory
public
static
PersonalInfo
Create
(
string
firstName
,
string
middleName
,
string
lastName
)
{
if
(
firstName
is
null
||
middleName
is
null
||
lastName
is
null
)
throw
new
InvalidValuesDomainException
<
PersonalInfo
>();
return
new
PersonalInfo
(
0
,
firstName
,
middleName
,
lastName
);
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/Visits/Relations/VisitMedicalImages/VisitMedicalImage.cs
View file @
ead3c9e3
using
Domain.Entities.Medicals.MedicalImages
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.Visits.Relations.VisitMedicalImages
;
// TODO: Convert result to a value object
public
sealed
class
VisitMedicalImage
(
int
id
)
:
Entity
(
id
)
public
sealed
class
VisitMedicalImage
:
Entity
{
#
region
Private
ctor
private
VisitMedicalImage
(
int
id
)
:
base
(
id
)
{
}
private
VisitMedicalImage
(
int
id
,
int
visitId
,
int
medicalImageId
)
:
base
(
id
)
{
VisitId
=
visitId
;
MedicalImageId
=
medicalImageId
;
Result
=
null
;
}
#
endregion
#
region
Properties
#
region
Visit
...
...
@@ -29,4 +44,28 @@ public sealed class VisitMedicalImage(int id) : Entity(id)
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
VisitMedicalImage
Create
(
int
visitId
,
int
medicalImageId
)
{
if
(
visitId
<=
0
||
medicalImageId
<=
0
)
throw
new
InvalidValuesDomainException
<
VisitMedicalImage
>();
return
new
VisitMedicalImage
(
0
,
visitId
,
medicalImageId
);
}
#
endregion
#
region
Add
result
public
void
AddResult
(
string
result
)
{
if
(
result
is
null
)
throw
new
InvalidValuesDomainException
<
VisitMedicalImage
>();
Result
=
result
;
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/Visits/Relations/VisitMedicalTests/VisitMedicalTest.cs
View file @
ead3c9e3
using
Domain.Entities.Medicals.MedicalTests
;
using
Domain.Entities.Visits.Relations.VisitMedicalImages
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.Visits.Relations.VisitMedicalTests
;
// TODO: Convert result to a value object
public
sealed
class
VisitMedicalTest
(
int
id
)
:
Entity
(
id
)
public
sealed
class
VisitMedicalTest
:
Entity
{
#
region
Private
ctor
private
VisitMedicalTest
(
int
id
)
:
base
(
id
)
{
}
private
VisitMedicalTest
(
int
id
,
int
visitId
,
int
medicalTestId
)
:
base
(
id
)
{
VisitId
=
visitId
;
MedicalTestId
=
medicalTestId
;
Result
=
null
;
}
#
endregion
#
region
Properties
#
region
Visit
...
...
@@ -29,4 +45,28 @@ public sealed class VisitMedicalTest(int id) : Entity(id)
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
VisitMedicalTest
Create
(
int
visitId
,
int
medicalTestId
)
{
if
(
visitId
<=
0
||
medicalTestId
<=
0
)
throw
new
InvalidValuesDomainException
<
VisitMedicalTest
>();
return
new
VisitMedicalTest
(
0
,
visitId
,
medicalTestId
);
}
#
endregion
#
region
Add
result
public
void
AddResult
(
string
result
)
{
if
(
result
is
null
)
throw
new
InvalidValuesDomainException
<
VisitMedicalTest
>();
Result
=
result
;
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/Visits/Relations/VisitMedicines/VisitMedicine.cs
View file @
ead3c9e3
using
Domain.Entities.Medicals.Medicines
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.Visits.Relations.VisitMedicines
;
public
sealed
class
VisitMedicine
(
int
id
)
:
Entity
(
id
)
public
sealed
class
VisitMedicine
:
Entity
{
#
region
Private
ctor
private
VisitMedicine
(
int
id
)
:
base
(
id
)
{
}
private
VisitMedicine
(
int
id
,
int
visitId
,
int
medicineId
,
int
number
)
:
base
(
id
)
{
VisitId
=
visitId
;
MedicineId
=
medicineId
;
Number
=
number
;
}
#
endregion
#
region
Properties
#
region
Visit
...
...
@@ -28,4 +42,18 @@ public sealed class VisitMedicine(int id) : Entity(id)
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
VisitMedicine
Create
(
int
visitId
,
int
medicineId
,
int
number
)
{
if
(
visitId
<=
0
||
medicineId
<=
0
||
number
<=
0
)
throw
new
InvalidValuesDomainException
<
VisitMedicine
>();
return
new
VisitMedicine
(
0
,
visitId
,
medicineId
,
number
);
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/Visits/Visit.cs
View file @
ead3c9e3
using
Domain.Entities.Medicals.Hospitals
;
using
Domain.Entities.Medicals.MedicalImages
;
using
Domain.Entities.Medicals.MedicalTests
;
using
Domain.Entities.Medicals.Medicines
;
using
Domain.Entities.People.Doctors
;
using
Domain.Entities.People.Patients
;
using
Domain.Entities.Visits.Relations.VisitMedicalImages
;
using
Domain.Entities.Visits.Relations.VisitMedicalTests
;
using
Domain.Entities.Visits.Relations.VisitMedicines
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.Visits
;
public
sealed
class
Visit
(
int
id
)
:
Entity
(
id
)
public
sealed
class
Visit
:
Entity
{
#
region
Private
ctor
private
Visit
(
int
id
)
:
base
(
id
)
{
}
private
Visit
(
int
id
,
int
patientId
,
int
doctorId
,
DateOnly
date
,
string
diagnosis
)
:
base
(
id
)
{
PatientId
=
patientId
;
DoctorId
=
doctorId
;
Date
=
date
;
Diagnosis
=
diagnosis
;
HospitalId
=
null
;
}
#
endregion
#
region
Properties
#
region
Patient
public
int
PatientId
{
get
;
set
;
}
public
Patient
Patient
{
get
;
set
;
}
=
null
!;
#
endregion
#
region
Doctor
public
int
DoctorId
{
get
;
set
;
}
public
Doctor
Doctor
{
get
;
set
;
}
=
null
!;
public
Hospital
?
Hospital
{
get
;
set
;
}
#
endregion
#
region
Additional
public
DateOnly
Date
{
get
;
set
;
}
public
string
Diagnosis
{
get
;
set
;
}
=
null
!;
#
region
Hospital
public
int
?
HospitalId
{
get
;
set
;
}
public
Hospital
?
Hospital
{
get
;
set
;
}
#
endregion
#
endregion
#
region
Navigations
public
ICollection
<
VisitMedicalImage
>
MedicalImages
{
get
;
set
;
}
=
[];
public
ICollection
<
VisitMedicalTest
>
MedicalTests
{
get
;
set
;
}
=
[];
public
ICollection
<
VisitMedicine
>
Medicines
{
get
;
set
;
}
=
[];
#
region
Medical
images
private
readonly
List
<
VisitMedicalImage
>
_medicalImages
=
[];
public
IReadOnlyCollection
<
VisitMedicalImage
>
MedicalImages
=>
_medicalImages
;
#
endregion
#
region
Medical
tests
private
readonly
List
<
VisitMedicalTest
>
_medicalTests
=
[];
public
IReadOnlyCollection
<
VisitMedicalTest
>
MedicalTests
=>
_medicalTests
;
#
endregion
#
region
Medicines
private
readonly
List
<
VisitMedicine
>
_medicines
=
[];
public
IReadOnlyCollection
<
VisitMedicine
>
Medicines
=>
_medicines
;
#
endregion
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
Visit
Create
(
int
patientId
,
int
doctorId
,
DateOnly
date
,
string
diagnosis
)
{
if
(
patientId
<=
0
||
doctorId
<=
0
||
diagnosis
is
null
)
throw
new
InvalidValuesDomainException
<
Visit
>();
return
new
Visit
(
0
,
patientId
,
doctorId
,
date
,
diagnosis
);
}
#
endregion
#
region
Add
medical
image
public
void
AddMedicalImage
(
MedicalImage
medicalImage
)
{
VisitMedicalImage
entry
;
try
{
entry
=
VisitMedicalImage
.
Create
(
Id
,
medicalImage
.
Id
);
}
catch
{
throw
;
}
_medicalImages
.
Add
(
entry
);
}
#
endregion
#
region
Add
medical
test
public
void
AddMedicalTest
(
MedicalTest
medicalTest
)
{
VisitMedicalTest
entry
;
try
{
entry
=
VisitMedicalTest
.
Create
(
Id
,
medicalTest
.
Id
);
}
catch
{
throw
;
}
_medicalTests
.
Add
(
entry
);
}
#
endregion
#
region
Add
medicine
public
void
AddMedicine
(
Medicine
medicine
,
int
number
)
{
VisitMedicine
entry
;
try
{
entry
=
VisitMedicine
.
Create
(
Id
,
medicine
.
Id
,
number
);
}
catch
{
throw
;
}
_medicines
.
Add
(
entry
);
}
#
endregion
#
region
Add
hospital
public
void
AddHospital
(
Hospital
hospital
)
{
if
(
hospital
is
null
)
throw
new
InvalidValuesDomainException
<
Visit
>();
Hospital
=
hospital
;
HospitalId
=
hospital
.
Id
;
}
#
endregion
#
endregion
...
...
Clinics.Backend/Domain/Entities/WaitingList/WaitingListRecord.cs
View file @
ead3c9e3
using
Domain.Entities.People.Doctors
;
using
Domain.Entities.People.Patients
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.WaitingList
;
public
sealed
class
WaitingListRecord
(
int
id
)
:
Entity
(
id
)
public
sealed
class
WaitingListRecord
:
Entity
{
#
region
Private
ctor
private
WaitingListRecord
(
int
id
)
:
base
(
id
)
{
}
private
WaitingListRecord
(
int
id
,
int
patientId
)
:
base
(
id
)
{
PatientId
=
patientId
;
IsServed
=
false
;
}
#
endregion
#
region
Properties
#
region
Patient
...
...
@@ -29,4 +41,28 @@ public sealed class WaitingListRecord(int id) : Entity(id)
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
WaitingListRecord
Create
(
int
patientId
)
{
if
(
patientId
<=
0
)
throw
new
InvalidValuesDomainException
<
WaitingListRecord
>();
return
new
WaitingListRecord
(
0
,
patientId
);
}
#
endregion
#
region
Link
to
doctor
public
void
LinkToDoctor
(
int
doctorId
)
{
if
(
doctorId
<=
0
)
throw
new
InvalidValuesDomainException
<
WaitingListRecord
>();
DoctorId
=
doctorId
;
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Exceptions/Base/DomainException.cs
0 → 100644
View file @
ead3c9e3
namespace
Domain.Exceptions.Base
;
public
abstract
class
DomainException
:
Exception
{
protected
DomainException
(
string
message
)
:
base
(
message
)
{
}
}
Clinics.Backend/Domain/Exceptions/InvalidValue/InvalidValuesDomainException.cs
0 → 100644
View file @
ead3c9e3
using
Domain.Exceptions.Base
;
using
Domain.Primitives
;
namespace
Domain.Exceptions.InvalidValue
;
public
class
InvalidValuesDomainException
<
TEntity
>
:
DomainException
where
TEntity
:
Entity
{
public
InvalidValuesDomainException
(
string
message
=
$"Values entered for entity
{
nameof
(
TEntity
)}
are invalid"
)
:
base
(
message
)
{
}
}
Clinics.Backend/Persistence/Configurations/People/Patients/PatientConfiguration.cs
View file @
ead3c9e3
...
...
@@ -10,6 +10,8 @@ internal class PatientConfiguration : IEntityTypeConfiguration<Patient>
{
builder
.
ToTable
(
nameof
(
Patient
));
builder
.
Ignore
(
patient
=>
patient
.
Age
);
builder
.
HasOne
(
patient
=>
patient
.
PersonalInfo
)
.
WithOne
()
.
HasForeignKey
<
Patient
>(
"PersonalInfoId"
)
...
...
@@ -21,6 +23,7 @@ internal class PatientConfiguration : IEntityTypeConfiguration<Patient>
builder
.
HasMany
(
patient
=>
patient
.
Visits
)
.
WithOne
(
visit
=>
visit
.
Patient
)
.
HasForeignKey
(
visit
=>
visit
.
PatientId
)
.
OnDelete
(
DeleteBehavior
.
NoAction
);
}
}
\ No newline at end of file
Clinics.Backend/Persistence/Configurations/People/Shared/PersonalInfoConfiguration.cs
View file @
ead3c9e3
...
...
@@ -10,8 +10,12 @@ internal class PersonalInfoConfiguration : IEntityTypeConfiguration<PersonalInfo
{
builder
.
ToTable
(
nameof
(
PersonalInfo
));
builder
.
Ignore
(
personalInfo
=>
personalInfo
.
FullName
);
builder
.
Property
(
personalInfo
=>
personalInfo
.
FirstName
).
HasMaxLength
(
50
);
builder
.
Property
(
personalInfo
=>
personalInfo
.
LastName
).
HasMaxLength
(
50
);
builder
.
Property
(
personalInfo
=>
personalInfo
.
MiddleName
).
HasMaxLength
(
50
);
}
}
Clinics.Backend/Persistence/Configurations/Visits/VisitConfiguration.cs
View file @
ead3c9e3
...
...
@@ -14,10 +14,12 @@ internal class VisitConfiguration : IEntityTypeConfiguration<Visit>
builder
.
HasOne
(
visit
=>
visit
.
Doctor
)
.
WithMany
()
.
HasForeignKey
(
visit
=>
visit
.
DoctorId
)
.
OnDelete
(
DeleteBehavior
.
NoAction
);
builder
.
HasOne
(
visit
=>
visit
.
Hospital
)
.
WithMany
()
.
HasForeignKey
(
visit
=>
visit
.
HospitalId
)
.
OnDelete
(
DeleteBehavior
.
NoAction
);
}
}
\ No newline at end of file
Clinics.Backend/Persistence/Migrations/20240816173549_Add_Amount_To_Medicine.Designer.cs
0 → 100644
View file @
ead3c9e3
// <auto-generated />
using
System
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Metadata
;
using
Microsoft.EntityFrameworkCore.Migrations
;
using
Microsoft.EntityFrameworkCore.Storage.ValueConversion
;
using
Persistence.Context
;
#
nullable
disable
namespace
Persistence.Migrations
{
[
DbContext
(
typeof
(
ClinicsDbContext
))]
[
Migration
(
"20240816173549_Add_Amount_To_Medicine"
)]
partial
class
Add_Amount_To_Medicine
{
/// <inheritdoc />
protected
override
void
BuildTargetModel
(
ModelBuilder
modelBuilder
)
{
#pragma warning disable 612, 618
modelBuilder
.
HasAnnotation
(
"ProductVersion"
,
"8.0.8"
)
.
HasAnnotation
(
"Relational:MaxIdentifierLength"
,
128
);
SqlServerModelBuilderExtensions
.
UseIdentityColumns
(
modelBuilder
);
modelBuilder
.
Entity
(
"Domain.Entities.Medicals.Diseases.Disease"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
string
>(
"Name"
)
.
IsRequired
()
.
HasMaxLength
(
50
)
.
HasColumnType
(
"nvarchar(50)"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"Disease"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.Medicals.Hospitals.Hospital"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
string
>(
"Name"
)
.
IsRequired
()
.
HasMaxLength
(
50
)
.
HasColumnType
(
"nvarchar(50)"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"Hospital"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.Medicals.MedicalImages.MedicalImage"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
string
>(
"Description"
)
.
HasMaxLength
(
250
)
.
HasColumnType
(
"nvarchar(250)"
);
b
.
Property
<
string
>(
"Name"
)
.
IsRequired
()
.
HasMaxLength
(
50
)
.
HasColumnType
(
"nvarchar(50)"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"MedicalImage"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.Medicals.MedicalTests.MedicalTest"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
string
>(
"Description"
)
.
HasMaxLength
(
250
)
.
HasColumnType
(
"nvarchar(250)"
);
b
.
Property
<
string
>(
"Name"
)
.
IsRequired
()
.
HasMaxLength
(
50
)
.
HasColumnType
(
"nvarchar(50)"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"MedicalTest"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.Medicals.Medicines.Medicine"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
int
>(
"Amount"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
decimal
>(
"Dosage"
)
.
HasColumnType
(
"numeric(9, 3)"
);
b
.
Property
<
int
>(
"MedicineFormId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
string
>(
"Name"
)
.
IsRequired
()
.
HasColumnType
(
"nvarchar(max)"
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"MedicineFormId"
);
b
.
ToTable
(
"Medicine"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.Medicals.Medicines.MedicineFormValues.MedicineForm"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
string
>(
"Name"
)
.
IsRequired
()
.
HasMaxLength
(
50
)
.
HasColumnType
(
"nvarchar(50)"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"MedicineForm"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Doctors.Doctor"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
int
>(
"PersonalInfoId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
int
>(
"StatusId"
)
.
HasColumnType
(
"int"
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"PersonalInfoId"
)
.
IsUnique
();
b
.
HasIndex
(
"StatusId"
);
b
.
ToTable
(
"Doctor"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Doctors.Shared.Constants.DoctorStatusValues.DoctorStatus"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
string
>(
"Name"
)
.
IsRequired
()
.
HasMaxLength
(
50
)
.
HasColumnType
(
"nvarchar(50)"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"DoctorStatus"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Doctors.Shared.DoctorPhone"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
int
?>(
"DoctorId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
string
>(
"Name"
)
.
HasMaxLength
(
50
)
.
HasColumnType
(
"nvarchar(50)"
);
b
.
Property
<
string
>(
"Phone"
)
.
IsRequired
()
.
HasMaxLength
(
20
)
.
HasColumnType
(
"nvarchar(20)"
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"DoctorId"
);
b
.
HasIndex
(
"Phone"
)
.
IsUnique
();
b
.
ToTable
(
"DoctorPhone"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Employees.Employee"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
b
.
Property
<
int
?>(
"AdditionalInfoId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
string
>(
"CenterStatus"
)
.
IsRequired
()
.
HasMaxLength
(
50
)
.
HasColumnType
(
"nvarchar(50)"
);
b
.
Property
<
bool
>(
"IsMarried"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"bit"
)
.
HasDefaultValue
(
false
);
b
.
Property
<
string
>(
"SerialNumber"
)
.
IsRequired
()
.
HasMaxLength
(
20
)
.
HasColumnType
(
"nvarchar(20)"
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"AdditionalInfoId"
)
.
IsUnique
()
.
HasFilter
(
"[AdditionalInfoId] IS NOT NULL"
);
b
.
ToTable
(
"Employee"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Employees.Relations.EmployeeFamilyMembers.EmployeeFamilyMember"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
int
>(
"EmployeeId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
int
>(
"FamilyMemberId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
int
>(
"RoleId"
)
.
HasColumnType
(
"int"
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"EmployeeId"
);
b
.
HasIndex
(
"FamilyMemberId"
);
b
.
HasIndex
(
"RoleId"
);
b
.
ToTable
(
"EmployeeFamilyMember"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Employees.Relations.EmployeeFamilyMembers.FamilyRoleValues.FamilyRole"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
string
>(
"Name"
)
.
IsRequired
()
.
HasMaxLength
(
50
)
.
HasColumnType
(
"nvarchar(50)"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"FamilyRole"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Employees.Shared.EmployeeAdditionalInfo"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
string
>(
"AcademicQualification"
)
.
HasMaxLength
(
50
)
.
HasColumnType
(
"nvarchar(50)"
);
b
.
Property
<
string
>(
"ImageUrl"
)
.
HasMaxLength
(
150
)
.
HasColumnType
(
"nvarchar(150)"
);
b
.
Property
<
string
>(
"JobStatus"
)
.
HasMaxLength
(
50
)
.
HasColumnType
(
"nvarchar(50)"
);
b
.
Property
<
string
>(
"Location"
)
.
HasMaxLength
(
50
)
.
HasColumnType
(
"nvarchar(50)"
);
b
.
Property
<
string
>(
"Specialization"
)
.
HasMaxLength
(
50
)
.
HasColumnType
(
"nvarchar(50)"
);
b
.
Property
<
DateOnly
?>(
"StartDate"
)
.
HasColumnType
(
"date"
);
b
.
Property
<
string
>(
"WorkPhone"
)
.
HasMaxLength
(
20
)
.
HasColumnType
(
"nvarchar(20)"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"EmployeeAdditionalInfo"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.FamilyMembers.FamilyMember"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"FamilyMember"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Patients.Patient"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
DateOnly
>(
"DateOfBirth"
)
.
HasColumnType
(
"date"
);
b
.
Property
<
int
>(
"GenderId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
int
>(
"PersonalInfoId"
)
.
HasColumnType
(
"int"
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"GenderId"
);
b
.
HasIndex
(
"PersonalInfoId"
)
.
IsUnique
();
b
.
ToTable
(
"Patient"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Patients.Relations.PatientDiseases.PatientDisease"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
int
>(
"DiseaseId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
int
>(
"PatientId"
)
.
HasColumnType
(
"int"
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"DiseaseId"
);
b
.
HasIndex
(
"PatientId"
,
"DiseaseId"
)
.
IsUnique
();
b
.
ToTable
(
"PatientDisease"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Patients.Relations.PatientMedicines.PatientMedicine"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
int
>(
"MedicineId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
int
>(
"Number"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
int
>(
"PatientId"
)
.
HasColumnType
(
"int"
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"MedicineId"
);
b
.
HasIndex
(
"PatientId"
,
"MedicineId"
)
.
IsUnique
();
b
.
ToTable
(
"PatientMedicine"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Shared.GenderValues.Gender"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
string
>(
"Name"
)
.
IsRequired
()
.
HasMaxLength
(
50
)
.
HasColumnType
(
"nvarchar(50)"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"Gender"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Shared.PersonalInfo"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
string
>(
"FirstName"
)
.
IsRequired
()
.
HasMaxLength
(
50
)
.
HasColumnType
(
"nvarchar(50)"
);
b
.
Property
<
string
>(
"LastName"
)
.
IsRequired
()
.
HasMaxLength
(
50
)
.
HasColumnType
(
"nvarchar(50)"
);
b
.
Property
<
string
>(
"MiddleName"
)
.
IsRequired
()
.
HasMaxLength
(
50
)
.
HasColumnType
(
"nvarchar(50)"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"PersonalInfo"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.Visits.Relations.VisitMedicalImages.VisitMedicalImage"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
int
>(
"MedicalImageId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
string
>(
"Result"
)
.
HasMaxLength
(
250
)
.
HasColumnType
(
"nvarchar(250)"
);
b
.
Property
<
int
>(
"VisitId"
)
.
HasColumnType
(
"int"
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"MedicalImageId"
);
b
.
HasIndex
(
"VisitId"
,
"MedicalImageId"
)
.
IsUnique
();
b
.
ToTable
(
"VisitMedicalImage"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.Visits.Relations.VisitMedicalTests.VisitMedicalTest"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
int
>(
"MedicalTestId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
string
>(
"Result"
)
.
HasMaxLength
(
250
)
.
HasColumnType
(
"nvarchar(250)"
);
b
.
Property
<
int
>(
"VisitId"
)
.
HasColumnType
(
"int"
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"MedicalTestId"
);
b
.
HasIndex
(
"VisitId"
,
"MedicalTestId"
)
.
IsUnique
();
b
.
ToTable
(
"VisitMedicalTest"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.Visits.Relations.VisitMedicines.VisitMedicine"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
int
>(
"MedicineId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
int
>(
"Number"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
int
>(
"VisitId"
)
.
HasColumnType
(
"int"
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"MedicineId"
);
b
.
HasIndex
(
"VisitId"
,
"MedicineId"
)
.
IsUnique
();
b
.
ToTable
(
"VisitMedicine"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.Visits.Visit"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
DateOnly
>(
"Date"
)
.
HasColumnType
(
"date"
);
b
.
Property
<
string
>(
"Diagnosis"
)
.
IsRequired
()
.
HasMaxLength
(
250
)
.
HasColumnType
(
"nvarchar(250)"
);
b
.
Property
<
int
>(
"DoctorId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
int
?>(
"HospitalId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
int
>(
"PatientId"
)
.
HasColumnType
(
"int"
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"DoctorId"
);
b
.
HasIndex
(
"HospitalId"
);
b
.
HasIndex
(
"PatientId"
);
b
.
ToTable
(
"Visit"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.WaitingList.WaitingListRecord"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
int
?>(
"DoctorId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
bool
>(
"IsServed"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"bit"
)
.
HasDefaultValue
(
false
);
b
.
Property
<
int
>(
"PatientId"
)
.
HasColumnType
(
"int"
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"DoctorId"
);
b
.
HasIndex
(
"PatientId"
);
b
.
ToTable
(
"WaitingListRecord"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"EmployeeEmployee"
,
b
=>
{
b
.
Property
<
int
>(
"RelatedEmployeesId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
int
>(
"RelatedToId"
)
.
HasColumnType
(
"int"
);
b
.
HasKey
(
"RelatedEmployeesId"
,
"RelatedToId"
);
b
.
HasIndex
(
"RelatedToId"
);
b
.
ToTable
(
"EmployeeEmployee"
);
});
modelBuilder
.
Entity
(
"Domain.Entities.Medicals.Medicines.Medicine"
,
b
=>
{
b
.
HasOne
(
"Domain.Entities.Medicals.Medicines.MedicineFormValues.MedicineForm"
,
"MedicineForm"
)
.
WithMany
()
.
HasForeignKey
(
"MedicineFormId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
Navigation
(
"MedicineForm"
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Doctors.Doctor"
,
b
=>
{
b
.
HasOne
(
"Domain.Entities.People.Shared.PersonalInfo"
,
"PersonalInfo"
)
.
WithOne
()
.
HasForeignKey
(
"Domain.Entities.People.Doctors.Doctor"
,
"PersonalInfoId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
HasOne
(
"Domain.Entities.People.Doctors.Shared.Constants.DoctorStatusValues.DoctorStatus"
,
"Status"
)
.
WithMany
()
.
HasForeignKey
(
"StatusId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
Navigation
(
"PersonalInfo"
);
b
.
Navigation
(
"Status"
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Doctors.Shared.DoctorPhone"
,
b
=>
{
b
.
HasOne
(
"Domain.Entities.People.Doctors.Doctor"
,
null
)
.
WithMany
(
"Phones"
)
.
HasForeignKey
(
"DoctorId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Employees.Employee"
,
b
=>
{
b
.
HasOne
(
"Domain.Entities.People.Employees.Shared.EmployeeAdditionalInfo"
,
"AdditionalInfo"
)
.
WithOne
()
.
HasForeignKey
(
"Domain.Entities.People.Employees.Employee"
,
"AdditionalInfoId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
);
b
.
HasOne
(
"Domain.Entities.People.Patients.Patient"
,
"Patient"
)
.
WithOne
()
.
HasForeignKey
(
"Domain.Entities.People.Employees.Employee"
,
"Id"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
Navigation
(
"AdditionalInfo"
);
b
.
Navigation
(
"Patient"
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Employees.Relations.EmployeeFamilyMembers.EmployeeFamilyMember"
,
b
=>
{
b
.
HasOne
(
"Domain.Entities.People.Employees.Employee"
,
"Employee"
)
.
WithMany
(
"FamilyMembers"
)
.
HasForeignKey
(
"EmployeeId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
HasOne
(
"Domain.Entities.People.FamilyMembers.FamilyMember"
,
"FamilyMember"
)
.
WithMany
()
.
HasForeignKey
(
"FamilyMemberId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
HasOne
(
"Domain.Entities.People.Employees.Relations.EmployeeFamilyMembers.FamilyRoleValues.FamilyRole"
,
"Role"
)
.
WithMany
()
.
HasForeignKey
(
"RoleId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
Navigation
(
"Employee"
);
b
.
Navigation
(
"FamilyMember"
);
b
.
Navigation
(
"Role"
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.FamilyMembers.FamilyMember"
,
b
=>
{
b
.
HasOne
(
"Domain.Entities.People.Patients.Patient"
,
"Patient"
)
.
WithOne
()
.
HasForeignKey
(
"Domain.Entities.People.FamilyMembers.FamilyMember"
,
"Id"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
Navigation
(
"Patient"
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Patients.Patient"
,
b
=>
{
b
.
HasOne
(
"Domain.Entities.People.Shared.GenderValues.Gender"
,
"Gender"
)
.
WithMany
()
.
HasForeignKey
(
"GenderId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
HasOne
(
"Domain.Entities.People.Shared.PersonalInfo"
,
"PersonalInfo"
)
.
WithOne
()
.
HasForeignKey
(
"Domain.Entities.People.Patients.Patient"
,
"PersonalInfoId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
Navigation
(
"Gender"
);
b
.
Navigation
(
"PersonalInfo"
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Patients.Relations.PatientDiseases.PatientDisease"
,
b
=>
{
b
.
HasOne
(
"Domain.Entities.Medicals.Diseases.Disease"
,
"Disease"
)
.
WithMany
(
"Patients"
)
.
HasForeignKey
(
"DiseaseId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
HasOne
(
"Domain.Entities.People.Patients.Patient"
,
"Patient"
)
.
WithMany
(
"Diseases"
)
.
HasForeignKey
(
"PatientId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
Navigation
(
"Disease"
);
b
.
Navigation
(
"Patient"
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Patients.Relations.PatientMedicines.PatientMedicine"
,
b
=>
{
b
.
HasOne
(
"Domain.Entities.Medicals.Medicines.Medicine"
,
"Medicine"
)
.
WithMany
(
"Patients"
)
.
HasForeignKey
(
"MedicineId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
HasOne
(
"Domain.Entities.People.Patients.Patient"
,
"Patient"
)
.
WithMany
(
"Medicines"
)
.
HasForeignKey
(
"PatientId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
Navigation
(
"Medicine"
);
b
.
Navigation
(
"Patient"
);
});
modelBuilder
.
Entity
(
"Domain.Entities.Visits.Relations.VisitMedicalImages.VisitMedicalImage"
,
b
=>
{
b
.
HasOne
(
"Domain.Entities.Medicals.MedicalImages.MedicalImage"
,
"MedicalImage"
)
.
WithMany
()
.
HasForeignKey
(
"MedicalImageId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
HasOne
(
"Domain.Entities.Visits.Visit"
,
"Visit"
)
.
WithMany
(
"MedicalImages"
)
.
HasForeignKey
(
"VisitId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
Navigation
(
"MedicalImage"
);
b
.
Navigation
(
"Visit"
);
});
modelBuilder
.
Entity
(
"Domain.Entities.Visits.Relations.VisitMedicalTests.VisitMedicalTest"
,
b
=>
{
b
.
HasOne
(
"Domain.Entities.Medicals.MedicalTests.MedicalTest"
,
"MedicalTest"
)
.
WithMany
()
.
HasForeignKey
(
"MedicalTestId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
HasOne
(
"Domain.Entities.Visits.Visit"
,
"Visit"
)
.
WithMany
(
"MedicalTests"
)
.
HasForeignKey
(
"VisitId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
Navigation
(
"MedicalTest"
);
b
.
Navigation
(
"Visit"
);
});
modelBuilder
.
Entity
(
"Domain.Entities.Visits.Relations.VisitMedicines.VisitMedicine"
,
b
=>
{
b
.
HasOne
(
"Domain.Entities.Medicals.Medicines.Medicine"
,
"Medicine"
)
.
WithMany
()
.
HasForeignKey
(
"MedicineId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
HasOne
(
"Domain.Entities.Visits.Visit"
,
"Visit"
)
.
WithMany
(
"Medicines"
)
.
HasForeignKey
(
"VisitId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
Navigation
(
"Medicine"
);
b
.
Navigation
(
"Visit"
);
});
modelBuilder
.
Entity
(
"Domain.Entities.Visits.Visit"
,
b
=>
{
b
.
HasOne
(
"Domain.Entities.People.Doctors.Doctor"
,
"Doctor"
)
.
WithMany
()
.
HasForeignKey
(
"DoctorId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
HasOne
(
"Domain.Entities.Medicals.Hospitals.Hospital"
,
"Hospital"
)
.
WithMany
()
.
HasForeignKey
(
"HospitalId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
);
b
.
HasOne
(
"Domain.Entities.People.Patients.Patient"
,
"Patient"
)
.
WithMany
(
"Visits"
)
.
HasForeignKey
(
"PatientId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
Navigation
(
"Doctor"
);
b
.
Navigation
(
"Hospital"
);
b
.
Navigation
(
"Patient"
);
});
modelBuilder
.
Entity
(
"Domain.Entities.WaitingList.WaitingListRecord"
,
b
=>
{
b
.
HasOne
(
"Domain.Entities.People.Doctors.Doctor"
,
"Doctor"
)
.
WithMany
()
.
HasForeignKey
(
"DoctorId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
);
b
.
HasOne
(
"Domain.Entities.People.Patients.Patient"
,
"Patient"
)
.
WithMany
()
.
HasForeignKey
(
"PatientId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
Navigation
(
"Doctor"
);
b
.
Navigation
(
"Patient"
);
});
modelBuilder
.
Entity
(
"EmployeeEmployee"
,
b
=>
{
b
.
HasOne
(
"Domain.Entities.People.Employees.Employee"
,
null
)
.
WithMany
()
.
HasForeignKey
(
"RelatedEmployeesId"
)
.
OnDelete
(
DeleteBehavior
.
Cascade
)
.
IsRequired
();
b
.
HasOne
(
"Domain.Entities.People.Employees.Employee"
,
null
)
.
WithMany
()
.
HasForeignKey
(
"RelatedToId"
)
.
OnDelete
(
DeleteBehavior
.
ClientCascade
)
.
IsRequired
();
});
modelBuilder
.
Entity
(
"Domain.Entities.Medicals.Diseases.Disease"
,
b
=>
{
b
.
Navigation
(
"Patients"
);
});
modelBuilder
.
Entity
(
"Domain.Entities.Medicals.Medicines.Medicine"
,
b
=>
{
b
.
Navigation
(
"Patients"
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Doctors.Doctor"
,
b
=>
{
b
.
Navigation
(
"Phones"
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Employees.Employee"
,
b
=>
{
b
.
Navigation
(
"FamilyMembers"
);
});
modelBuilder
.
Entity
(
"Domain.Entities.People.Patients.Patient"
,
b
=>
{
b
.
Navigation
(
"Diseases"
);
b
.
Navigation
(
"Medicines"
);
b
.
Navigation
(
"Visits"
);
});
modelBuilder
.
Entity
(
"Domain.Entities.Visits.Visit"
,
b
=>
{
b
.
Navigation
(
"MedicalImages"
);
b
.
Navigation
(
"MedicalTests"
);
b
.
Navigation
(
"Medicines"
);
});
#pragma warning restore 612, 618
}
}
}
Clinics.Backend/Persistence/Migrations/20240816173549_Add_Amount_To_Medicine.cs
0 → 100644
View file @
ead3c9e3
using
Microsoft.EntityFrameworkCore.Migrations
;
#
nullable
disable
namespace
Persistence.Migrations
{
/// <inheritdoc />
public
partial
class
Add_Amount_To_Medicine
:
Migration
{
/// <inheritdoc />
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
AddColumn
<
int
>(
name
:
"Amount"
,
table
:
"Medicine"
,
type
:
"int"
,
nullable
:
false
,
defaultValue
:
0
);
}
/// <inheritdoc />
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropColumn
(
name
:
"Amount"
,
table
:
"Medicine"
);
}
}
}
Clinics.Backend/Persistence/Migrations/ClinicsDbContextModelSnapshot.cs
View file @
ead3c9e3
...
...
@@ -110,6 +110,9 @@ namespace Persistence.Migrations
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
int
>(
"Amount"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
decimal
>(
"Dosage"
)
.
HasColumnType
(
"numeric(9, 3)"
);
...
...
Clinics.Backend/Persistence/Repositories/Base/Repositroy.cs
View file @
ead3c9e3
...
...
@@ -29,7 +29,9 @@ public class Repositroy<TEntity> : IRepository<TEntity> where TEntity : Entity
public
async
Task
<
TEntity
>
CreateAsync
(
TEntity
entity
)
{
return
await
_context
.
Set
<
TEntity
>().
FirstAsync
(
e
=>
e
.
Id
==
entity
.
Id
);
var
query
=
await
_context
.
Set
<
TEntity
>().
AddAsync
(
entity
);
await
_context
.
SaveChangesAsync
();
return
query
.
Entity
;
}
#
endregion
...
...
@@ -43,7 +45,7 @@ public class Repositroy<TEntity> : IRepository<TEntity> where TEntity : Entity
public
async
Task
<
ICollection
<
TEntity
>>
GetAllAsync
()
{
return
await
_context
.
Set
<
TEntity
>().
ToListAsync
<
TEntity
>
();
return
await
_context
.
Set
<
TEntity
>().
ToListAsync
();
}
#
endregion
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment